<?php

namespace SGC\eGiftCard\Hooks\Handler;

defined('ABSPATH') || exit; // Prevent direct file access.

class MenuHandler
{
    /**
     * Initialize the menu.
     *
     * This method sets up the main menu page and submenu pages.
     */
    public static function init()
    {
        // Add the main menu page.
        add_menu_page(
            esc_html__('eGift Card', 'smart-gift-card'), // Page Title
            esc_html__('eGift Card', 'smart-gift-card'), // Menu Title
            'manage_options', // Capability
            SMART_GIFT_CARD_PLUGIN_ASSET_ID, // Menu Slug
            [new self(), 'loadView'], // Callback
            'dashicons-index-card', // Dashicon
            54
        );
    }

    /**
     * Load the admin view.
     *
     * This method includes the admin view file.
     */
    public function loadView()
    {
        // Check user capabilities.
        if (!current_user_can('manage_options')) {
            wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'smart-gift-card'));
        }

        // Load the admin view.
        include_once( SMART_GIFT_CARD_PLUGIN_BASE_PATH . 'app/views/admin.php' );
    }
}
