<?php
namespace orderflow\Admin;

use orderflow\License;
use orderflow\Traits\Core;

class Register_Menus {

    use Core;
    private $incomplete_order;
    private $incomplete_orders_dashboard;
    private $core;
    public function __construct( $incomplete_order, $incomplete_orders_dashboard,$core ) {
        $this->incomplete_order = $incomplete_order;
        $this->incomplete_orders_dashboard = $incomplete_orders_dashboard;
        $this->core = $core;
        add_action('admin_menu', [$this, 'register_admin_menu']);
    }

    public function register_admin_menu() {
        $general_settings = new General_Settings();
        $fb_Settings = new Fb_Settings();
        $incomplete_order = $this->incomplete_order;
        $incomplete_orders_dashboard = $this->incomplete_orders_dashboard;

        // Main menu
        add_menu_page(
            'Order Flow',    // Page title
            'Order Flow',    // Menu title
            'manage_options',
            'orderflow',
            [$incomplete_orders_dashboard, 'render_dashboard'],
            'dashicons-shield',
            5
        );

        // First submenu: Dashboard (same callback as main menu)
        add_submenu_page(
            'orderflow',
            'Dashboard',
            'Dashboard',
            'manage_options',
            'orderflow',
            [$incomplete_orders_dashboard, 'render_dashboard']
        );



        if ( self::is_license_active() ) {
            add_submenu_page(
                'orderflow',
                'Incomplete Orders',
                'Incomplete Orders',
                'manage_options',
                'orderflow-incomplete-orders',
                [$incomplete_order, 'render_settings']
            );

            add_submenu_page(
                'orderflow',
                'Fraud Checker',
                'Fraud Checker',
                'manage_options',
                'orderflow-courier',
                [$general_settings, 'render_courier_settings_page']
            );

            add_submenu_page(
                'orderflow',
                'Fraud Block',
                'Fraud Block',
                'manage_options',
                'orderflow-fraud-customer-block',
                [$general_settings, 'render_fraud_customer_block_settings_page']
            );
            add_submenu_page(
                'orderflow',
                'Partial Payment',
                'Partial Payment',
                'manage_options',
                'orderflow-prtial-payment',
                [$general_settings, 'render_partial_payment_settings_page']
            );

            add_submenu_page(
                'orderflow',
                'FB Settings',
                'FB Settings',
                'manage_options',
                'orderflow-fb-settings',
                [$fb_Settings, 'render_settings']
            );
        }

        add_submenu_page(
            'orderflow',
            'ads License',
            'License',
            'manage_options',
            'orderflow-license-settings',
            [$this->core, 'render_license_page']
        );
    }

}
