<?php
if (!defined('ABSPATH')) exit;

class IPM_Support_Admin {

    public static function render_support_list() {

        $action = $_GET['action'] ?? '';
        $index  = isset($_GET['index']) ? intval($_GET['index']) : null;

        // 🔹 ROUTER
        if ($action === 'add') {
            self::render_form();
            return;
        }

        if ($action === 'edit' && $index !== null) {
            self::render_form($index);
            return;
        }

        // 🔹 DEFAULT: LIST VIEW
        include IPM_PLUGIN_DIR . 'includes/support/admin/support-list.php';
    }

    public static function render_support_types() {
        include IPM_PLUGIN_DIR . 'includes/support/admin/support-types.php';
    }

    /**
     * Add/Edit Form
     */
    private static function render_form($index = null) {

        $items = get_option('ipm_support_type_details', []);
        $item  = $index !== null && isset($items[$index]) ? $items[$index] : null;

        include IPM_PLUGIN_DIR . 'includes/support/admin/support-form.php';
    }
}
