<?php
/**
 * Enqueue styles/scripts across the site.
 *
 * @author     FutrX
 * @year       2023
 * @package    NoMoreBots
 * @subpackage NoMoreBots
 */

namespace NoMoreBots;

use NoMoreBots\Utils\OTP\OTP as OTPUtils;

class Enqueue {

	public function __construct() {
		add_action( 'admin_enqueue_scripts', array( $this, 'adminStyles' ) );
		add_action( 'admin_enqueue_scripts', array( $this, 'adminScripts' ) );
	}

	/**
	 * Enqueue the admin styles.
	 *
	 * @return void
	 */
	public function adminStyles(): void {
		wp_enqueue_style(
			NOMOREBOTS_PLUGINTEXTDOMAIN . 'admin',
			NOMOREBOTS_PLUGINURL . 'assets/css/admin.css',
			array(),
			NOMOREBOTS_PLUGINVERSION
		);
		wp_enqueue_style(
			NOMOREBOTS_PLUGINTEXTDOMAIN . 'admin-otp',
			NOMOREBOTS_PLUGINURL . 'assets/css/otp.css',
			array(),
			NOMOREBOTS_PLUGINVERSION
		);
	}

	/**
	 * Enqueue the admin scripts.
	 *
	 * @return void
	 */
	public function adminScripts(): void {
		// Add here any admin scripts needed.
		wp_enqueue_script(
			NOMOREBOTS_PLUGINTEXTDOMAIN . 'admin-pages',
			NOMOREBOTS_PLUGINURL . 'assets/js/admin/pages.js',
			array(),
			NOMOREBOTS_PLUGINVERSION,
			true
		);
		wp_localize_script(
			NOMOREBOTS_PLUGINTEXTDOMAIN . 'admin-pages',
			'NOMOREBOTS',
			array(
				'Random_OTP_Secret' => OTPUtils::generateOTPSecret( 32 ),
			)
		);
	}
}
