<?php
namespace ARCHM\Admin;

if ( ! defined('ABSPATH') ) {
    // phpcs:ignore Universal.PHP.RequireExitDieParentheses.Missing
    exit;
}

class Notice {

    public function __construct() {
        //add_action('admin_notices', [$this, "notice"]);
        add_action('in_admin_header', [ $this, 'add_archive_status_notice' ]);
    }

    // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
    public function notice(): void {
        $this->display_notice_on_db_switch();
        $this->display_notice_on_background_process();
    }

    /**
     * Admin notice on switch database
     *
     * @return void
     * @since 1.0
     * @author Siam Maruf
     */
    // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
    public function display_notice_on_db_switch(): void {
        $wp_db_switch = get_option('archm_db_switch');
        if ( 1 === (int) $wp_db_switch ) {
            echo '<div class="notice notice-info --wa-archive-db-switch-notice"><p>';
            esc_html__('The Order database was switched by an archive database!', 'archive-master');
            echo '</p></div>';
        }
    }

    // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
    public function display_notice_on_background_process(): void {
        $bg_process = get_option('_archm_background_process_running');
        $page_url = admin_url('admin.php?page=master-archives#/logs');
        //if ($bg_process) {
            // echo '<div class="notice notice-success is-dismissible --wa-archive-db-switch-notice"><p>';
            // esc_html__('Archive orders are being processed in the background.', 'archive-master');
            // echo '</p><p><a class="button button-primary" href="' . esc_url($page_url) . '">';
            // esc_html__('View progress', 'archive-master');
            // echo '</a></p></div>';
        //}
    }

    public function add_archive_status_notice() {
        $screen = get_current_screen();
        if ( 'dashboard' === $screen->id ) {
            ?>
                <div id="archive-status-notice">
                    
                </div>
            <?php
        }
    }
}
