<?php

namespace Itgalaxy\Elementor\Form\Infusionsoft\Integration\Admin\PageParts;

use Itgalaxy\Elementor\Form\Infusionsoft\Integration\Includes\Bootstrap;
use Itgalaxy\Elementor\Form\Infusionsoft\Integration\Includes\Helper;
use Itgalaxy\PluginCommon\AdminGenerator\Elements\Root;

class ReloadFieldsPagePart
{
    /**
     * @return void
     */
    public static function render()
    {
        if (!Helper::isActive()) {
            return;
        }

        echo ' <form action="'
            . esc_url(admin_url() . 'admin.php?page=' . Bootstrap::OPTIONS_KEY)
            . '" method="post">';

        Root::render(
            [
                'type' => 'div',
                'classes' => ['mb-3'],
                'childes' => [
                    [
                        'type' => 'button',
                        'classes' => ['btn-primary'],
                        'text' => esc_html__('Reload fields data from CRM', 'el-pro-form-infusionsoft-integration'),
                        'attributes' => [
                            'type' => 'submit',
                            'name' => 'elementorInfusionsoftReloadFieldsCache',
                        ],
                    ],
                ],
            ]
        );

        echo '</form>';
    }
}
