<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Action\View;

use DropshippingExportFreeVendor\WPDesk\View\Renderer\Renderer;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportLogicDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Factory\DataProviderFactory;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Form\ExportLogicForm;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Request\Request;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Service\Listener\Items\Registrable\Registrable;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\View\Abstraction\Displayable;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Converter\FileConverterService;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Locator\FileLocatorService;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\View\FormView;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Helper\PluginHelper;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Action\Process\Form\ExportLogicFormProcessAction;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Service\Listener\Items\Initable\Initable;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Form\Fields\ExportLogicFormFields;
/**
 * Class ImportCsvSelectorViewAction, csv selector view action.
 *
 * @package WPDesk\Library\DropshippingExport\Action\View
 */
class ExportLogicViewAction implements Displayable, Registrable, Initable
{
    const FIRST_PAGE = 1;
    /**
     * @var Renderer
     */
    private $renderer;
    /**
     * @var ExportLogicForm
     */
    private $form;
    /**
     * @var PluginHelper
     */
    private $plugin_helper;
    /**
     * @var Request
     */
    private $request;
    /**
     * @var FileConverterService
     */
    private $converter_service;
    /**
     * @var DataProviderFactory
     */
    private $data_provider_factory;
    /**
     * @var FileLocatorService
     */
    private $file_locator;
    public function __construct(Request $request, Renderer $renderer, DataProviderFactory $data_provider_factory, ExportLogicForm $form, FileConverterService $converter, FileLocatorService $file_locator, PluginHelper $plugin_helper)
    {
        $this->renderer = $renderer;
        $this->form = $form;
        $this->plugin_helper = $plugin_helper;
        $this->request = $request;
        $this->converter_service = $converter;
        $this->data_provider_factory = $data_provider_factory;
        $this->file_locator = $file_locator;
    }
    public function register(): array
    {
        return [ExportLogicFormProcessAction::class];
    }
    public function init()
    {
        $uid = $this->request->get_param('get.uid')->getAsString();
        $data_provider = $this->data_provider_factory->create_by_class_name(ExportLogicDataProvider::class, ['postfix' => $uid]);
        $this->form->set_data($data_provider);
    }
    public function show()
    {
        $uid = $this->request->get_param('get.uid')->getAsString();
        $data = ['title' => __('Conditional Logic', 'dropshipping-export-free'), 'edit' => \false, 'mode' => $this->request->get_param('get.mode')->getAsString(), 'form' => new FormView($this->form, $this->renderer), 'previous_step' => $this->plugin_helper->generate_url_by_view(ExportTypeViewAction::class, ['uid' => $uid]), 'renderer' => $this->renderer, 'step' => 2];
        $this->renderer->output_render('Export/ExportLogic', $data);
    }
}
