<?php
/**
 * Abandoned cart recovery admin page.
 *
 * @package SuiteMkt3k
 */

namespace SuiteMkt3k\Admin\Pages;

use SuiteMkt3k\Modules\Cart_Recovery\Cart_Recovery_Manager;
use SuiteMkt3k\Security\Capabilities;
use SuiteMkt3k\Security\Nonces;

defined( 'ABSPATH' ) || exit;

final class Cart_Recovery_Page extends Base_Page {

	protected static string $slug        = 'suitemkt3k-cart-recovery';
	protected static string $cap         = Capabilities::EDIT_CAMPAIGN;
	protected static bool   $requires_wc = true;

	public static function render(): void {
		static::$page_title    = __( 'Abandoned Cart Recovery', 'suitemkt3k' );
		static::$page_subtitle = __( 'Recover lost sales with personalised emails and discount coupons', 'suitemkt3k' );
		parent::render();
	}

	protected static function content(): void {
		$view = \SuiteMkt3k\Utils\Sanitizer::get( 'view', 'key' );
		if ( '' === $view ) {
			$view = 'list';
		}
		$nonce = Nonces::create( Nonces::ADMIN_ACTION );

		if ( 'template' === $view ) {
			include SUITEMKT3K_PATH . 'includes/admin/views/cart-template-editor.php';
			return;
		}
		$carts = Cart_Recovery_Manager::list();
		include SUITEMKT3K_PATH . 'includes/admin/views/cart-list.php';
	}
}
