<?php
/**
 * Class Pixelio_Cart_Abandon_Recovery_More_Admin_Dialog_Popup
 *
 * Handles a dialog popup in the WordPress admin.
 * Allows displaying a message with two possible actions (e.g., cancel / confirm),
 * with custom JavaScript callbacks for each action.
 *
 * @package PixelioCartAbandonRecoveryMore\Admin\Views\Reusable
 */

namespace PixelioCartAbandonRecoveryMore\Admin\Views\Reusable;

use PixelioCartAbandonRecoveryMore\Includes\Utils\Pixelio_Cart_Abandon_Recovery_More_Util;

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

/**
 * Class Pixelio_Cart_Abandon_Recovery_More_Admin_Dialog_Popup
 *
 * Handles a dialog popup in the WordPress admin.
 * Allows displaying a message with two possible actions (e.g., cancel / confirm),
 * with custom JavaScript callbacks for each action.
 *
 * @package PixelioCartAbandonRecoveryMore\Admin\Views\Reusable
 */
class Pixelio_Cart_Abandon_Recovery_More_Admin_Dialog_Popup{

	/**
	 * Main text displayed in the popup.
	 *
	 * @var string
	 */
	protected $texte;

	/**
	 * Label for the first action button (e.g., "Cancel").
	 *
	 * @var string
	 */
	protected $action_1;

	/**
	 * Label for the second action button (e.g., "Confirm").
	 *
	 * @var string
	 */
	protected $action_2;

	/**
	 * Title displayed at the top of the popup.
	 *
	 * @var string
	 */
	private $title;

	/**
	 * JavaScript callback function name for the first action button.
	 *
	 * @var string
	 */
	private $action_1_callback;

	/**
	 * JavaScript callback function name for the second action button.
	 *
	 * @var string
	 */
	private $action_2_callback;

	/**
	 * Constructor.
	 *
	 * Initializes the popup with title, text, buttons, and JS callbacks.
	 *
	 * @param string $title Title of the popup.
	 * @param string $texte Main message text of the popup.
	 * @param string $action_1 Label for the first action button.
	 * @param string $action_2 Label for the second action button.
	 * @param string $action_1_callback JS function name for the first button callback.
	 * @param string $action_2_callback JS function name for the second button callback.
	 */
	public function __construct($title, $texte, $action_1, $action_2, $action_1_callback, $action_2_callback)
	{
		$this->title = $title;
		$this->texte = $texte;
		$this->action_1 = $action_1;
		$this->action_2 = $action_2;
		$this->action_1_callback = $action_1_callback;
		$this->action_2_callback = $action_2_callback;
	}

	/**
	 * Renders the popup HTML, CSS, and JavaScript.
	 *
	 * Handles the display of the modal dialog with two buttons, styling, and JS logic
	 * for callbacks and closing the popup.
	 *
	 * @return void
	 */
	public function pixelio_cart_abandon_recovery_more_get_views()
	{
		?>
		<div id="pixelio-cart-abandon-recovery-more-remove-popup" class="pixelio-cart-abandon-recovery-more-popup-overlay" style="display:none;">
			<div class="pixelio-cart-abandon-recovery-more-popup-card">
				<h2><?php echo esc_attr($this->title); ?></h2>
				<p><?php echo esc_attr($this->texte); ?></p>
				<div class="pixelio-cart-abandon-recovery-more-popup-actions">
					<button
						class="pixelio-cart-abandon-recovery-more-popup-cancel"><?php echo esc_attr($this->action_1); ?></button>
					<button
						class="pixelio-cart-abandon-recovery-more-popup-confirm"><?php echo esc_attr($this->action_2); ?></button>
				</div>
			</div>
		</div>
		<?php
	}
}

