<?php
/**
 * Admin template for ConvertForce welcome/dashboard (React).
 *
 * @var string $version
 * @var string $welcome_url
 * @var string $campaigns_url
 * @var string $new_campaign_url
 * @var string $docs_url
 * @var string $support_url
 * @var string $pro_url
 */

if (!defined('ABSPATH')) {
    exit;
}

use Convertforce\Utils\ViewUtils;

// Ensure WordPress React (wp-element) is loaded for the admin app.
wp_enqueue_script('wp-element');

$admin_asset = CONVERTFORCE_DIR . '/build/admin-page.asset.php';
$admin_deps  = [];
$admin_ver   = CONVERTFORCE_VERSION;
if (file_exists($admin_asset)) {
    $asset      = include $admin_asset;
    $admin_deps = $asset['dependencies'] ?? [];
    $admin_ver  = $asset['version'] ?? $admin_ver;
}

wp_register_script(
    'convertforce-admin',
    CONVERTFORCE_URL . '/build/admin-page.js',
    $admin_deps,
    $admin_ver,
    true
);
wp_localize_script('convertforce-admin', 'CONVERTFORCE_ADMIN', [
    'version'        => $version,
    'welcomeUrl'     => $welcome_url,
    'campaignsUrl'   => $campaigns_url,
    'newCampaignUrl' => $new_campaign_url,
    'docsUrl'        => $docs_url,
    'supportUrl'     => $support_url,
]);
wp_enqueue_script('convertforce-admin');

ViewUtils::enqueue_styles('admin-page-style', 'admin-page-style.css');
?>
<div class="wrap convertforce-admin-wrap-outer">
    <div id="convertforce-welcome-root"></div>
</div>
