<?php
/**
 * Points status content view.
 *
 * @package Awesomemotive\Rewardswp\Views\Admin\Parts
 * @since 1.0.0
 */

namespace Awesomemotive\Rewardswp\Views\Admin\Parts;

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

use Awesomemotive\Rewardswp\Abstracts\AbstractView;
use Awesomemotive\Rewardswp\Interfaces\ViewInterface;
use Awesomemotive\Rewardswp\Settings\Options\Points\CurrencyPluralOption;
use Awesomemotive\Rewardswp\Settings\Options\Points\CurrencySingularOption;
use Awesomemotive\Rewardswp\Settings\Options\Points\PointsEnabledOption;
use Awesomemotive\Rewardswp\Settings\Options\Points\PointsExpirationOption;
use function Awesomemotive\Rewardswp\Helpers\get_option_value;
use function Awesomemotive\Rewardswp\Helpers\get_view_component;
use function Awesomemotive\Rewardswp\Helpers\kses;
use Awesomemotive\Rewardswp\Helpers\IconHelper;

/**
 * Class PointsStatusContentView
 *
 * @since 1.0.0
 */
class PointsStatusContentView extends AbstractView implements ViewInterface {
	/**
	 * Icon helper instance.
	 *
	 * @var IconHelper
	 */
	private IconHelper $icon_helper;

	/**
	 * Constructor.
	 *
	 * @param IconHelper $icon_helper
	 */
	public function __construct( IconHelper $icon_helper ) {
		$this->icon_helper = $icon_helper;
	}

	/**
	 * Render the template.
	 *
	 * @since 1.0.0
	 *
	 * @param array $args
	 *
	 * @return void
	 */
	public function render( array $args = [] ): void {
		?>

		<div class="py-5">
			<div class="gap-8 md:flex md:items-center">
				<div class="md:w-1/3 flex-none">
					<label for="rewardswp_settings[points][points_enabled]" class="text-sm font-semibold">
						<?php esc_html_e( 'Program Status', 'rewardswp' ); ?>
						<?php
						echo wp_kses(
							get_view_component(
								'badge',
								[
									'text'               => esc_html__( 'Active', 'rewardswp' ),
									'style'              => 'active',
									'additional_classes' => 'ml-2',
									'x-show'             => 'pointsEnabled',
								]
							),
							kses()
						);
						?>
						<?php
						echo wp_kses(
							get_view_component(
								'badge',
								[
									'text'               => esc_html__( 'Inactive', 'rewardswp' ),
									'style'              => 'inactive',
									'additional_classes' => 'ml-2',
									'x-show'             => '!pointsEnabled',
								]
							),
							kses()
						);
						?>
					</label>
				</div>
				<div class="md:w-2/3">

					<?php

					echo wp_kses(
						get_view_component(
							'toggle',
							[
								'section'    => 'points',
								'name'       => 'points_enabled',
								'label'      => esc_html__( 'Program Status', 'rewardswp' ),
								'is_checked' => get_option_value( PointsEnabledOption::class ),
								'on_click'   => 'pointsEnabled = !pointsEnabled',
							]
						),
						kses()
					);

					?>

				</div>
			</div>
		</div>

		<?php
	}
}
