<?php
/**
 * Admin menu registration.
 *
 * @package OpusPriceBuilder\Admin
 */

declare(strict_types=1);

namespace OpusPriceBuilder\Admin;

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

/**
 * Handles admin menu registration.
 */
class AdminMenu {

	/**
	 * Constructor.
	 */
	public function __construct() {
		add_action( 'admin_menu', array( $this, 'registerMenu' ) );
	}

	/**
	 * Register the admin menu.
	 *
	 * @return void
	 */
	public function registerMenu(): void {
		add_menu_page(
			__( 'Price Builder', 'opus-price-builder' ),
			__( 'Price Builder', 'opus-price-builder' ),
			'manage_woocommerce',
			'opus-price-builder',
			array( $this, 'renderPage' ),
			'dashicons-money-alt',
			56
		);

		add_submenu_page(
			'opus-price-builder',
			__( 'Layout Builder', 'opus-price-builder' ),
			__( 'Layout Builder', 'opus-price-builder' ),
			'manage_woocommerce',
			'opus-price-builder',
			array( $this, 'renderPage' )
		);

		add_submenu_page(
			'opus-price-builder',
			__( 'Settings', 'opus-price-builder' ),
			__( 'Settings', 'opus-price-builder' ),
			'manage_woocommerce',
			'price-builder-settings',
			array( $this, 'renderSettingsPage' )
		);
	}

	/**
	 * Render the main page (React app container).
	 *
	 * @return void
	 */
	public function renderPage(): void {
		echo '<div id="opus-price-builder-app" class="oppb-app-wrapper"></div>';
	}

	/**
	 * Render the templates page.
	 *
	 * @return void
	 */
	public function renderTemplatesPage(): void {
		echo '<div id="opus-price-builder-templates" class="oppb-app-wrapper"></div>';
	}

	/**
	 * Render the settings page.
	 *
	 * @return void
	 */
	public function renderSettingsPage(): void {
		echo '<div id="opus-price-builder-settings" class="oppb-app-wrapper"></div>';
	}
}
