<?php

$page = $_GET['page'] ?? 'dashboard';

$pages = [
    'dashboard' => '/pages/dashboard/index.php',

    'user' => '/pages/users/user.php',
    'edit-user' => '/pages/users/edit-user.php',
    'update-user' => '/pages/users/update-user.php',
    'balance' => '/pages/users/balance.php',
    'update-balance' => '/pages/users/update-balance.php',

    'profile' => '/pages/profile/profile.php',
    'update-profile' => '/pages/profile/update-profile.php',

    'admin' => '/pages/admin/admin.php',
    'add-admin' => '/pages/admin/add-admin.php',
    'edit-admin' => '/pages/admin/edit-admin.php',
    'update-admin' => '/pages/admin/update-admin.php',

    'bank' => '/pages/bank/bank.php',
    'add-bank' => '/pages/bank/add-bank.php',
    'edit-bank' => '/pages/bank/edit-bank.php',
    'update-bank' => '/pages/bank/update-bank.php',

    'banner' => '/pages/banner/banner.php',
    'add-banner' => '/pages/banner/add-banner.php',
    'edit-banner' => '/pages/banner/edit-banner.php',
    'update-banner' => '/pages/banner/update-banner.php',

    'promo' => '/pages/promo/promo.php',
    'add-promo' => '/pages/promo/add-promo.php',
    'edit-promo' => '/pages/promo/edit-promo.php',
    'update-promo' => '/pages/promo/update-promo.php',
    
    'popup' => '/pages/popup/popup.php',
    'update-popup' => '/pages/popup/update-popup.php',

    'deposit' => '/pages/transaction/deposit.php',
    'deposit-history' => '/pages/transaction/deposit-history.php',
    'update-deposit' => '/pages/transaction/update-deposit.php',
    'withdrawal' => '/pages/transaction/withdrawal.php',
    'withdrawal-test' => '/pages/transaction/wd-test.php',
    'withdrawal-history' => '/pages/transaction/withdrawal-history.php',
    'update-withdrawal' => '/pages/transaction/update-withdrawal.php',

    'login' => '/pages/auth/index.php',
    'proses-login' => '/pages/auth/auth_login.php',
    'logout' => '/pages/auth/auth_logout.php',

    'website' => '/pages/settings/website.php',
    'update-website' => '/pages/settings/update-website.php',

    'data-json' => '/pages/dashboard/get_data_json.php',

    'error-404' => '/pages/error/404.php',
    'error-403' => '/pages/error/403.php',
];

if (array_key_exists($page, $pages)) {
    $filePath = __DIR__ . $pages[$page];

    if (file_exists($filePath)) {
        include $filePath;
    } else {
        header("Location: error-404");
    }
} else {
    header("Location: error-404");
}
