<?php

use Illuminate\Support\Facades\Route;

Route::group(['namespace' => 'User', 'middleware' => ['auth', 'cookie', 'maintenance']], function() {
    Route::get('/', [\App\Http\Controllers\User\Auth\AuthController::class, 'home'])->withoutMiddleware(['auth']);
    Route::group(['prefix' => 'auth'], function() {
        Route::get('activate/{target:token}', [\App\Http\Controllers\User\Auth\ActivateAccountController::class, 'activate'])->withoutMiddleware(['auth', 'cookie']);
        Route::get('login', [\App\Http\Controllers\User\Auth\LoginController::class, 'get'])->withoutMiddleware(['auth'])->name('user.login');
        Route::post('login', [\App\Http\Controllers\User\Auth\LoginController::class, 'post'])->withoutMiddleware(['auth'])->name('user.login');
        Route::get('logout', [\App\Http\Controllers\User\Auth\AuthController::class, 'logout'])->withoutMiddleware(['auth']);
        if (website_config('main')->is_register_enabled) {
            Route::get('register', [\App\Http\Controllers\User\Auth\RegisterController::class, 'get'])->withoutMiddleware(['auth'])->name('user.register');
            Route::post('register', [\App\Http\Controllers\User\Auth\RegisterController::class, 'post'])->withoutMiddleware(['auth'])->name('user.register');
        }
        if (website_config('main')->is_reset_password_enabled) {
            Route::get('reset/{token:hash?}', [\App\Http\Controllers\User\Auth\ResetPasswordController::class, 'get'])->withoutMiddleware(['auth'])->name('user.reset');
            Route::post('reset/{token:hash?}', [\App\Http\Controllers\User\Auth\ResetPasswordController::class, 'post'])->withoutMiddleware(['auth'])->name('user.reset');
        }
    });
    Route::group(['prefix' => 'account'], function() {
        Route::get('create_api_key', [\App\Http\Controllers\User\AccountController::class, 'create_api_key']);
        Route::get('profile', [\App\Http\Controllers\User\AccountController::class, 'profile']);
        Route::get('log/login', [\App\Http\Controllers\User\AccountController::class, 'login_log']);
        Route::get('log/balance', [\App\Http\Controllers\User\AccountController::class, 'balance_log']);
        Route::get('log/balance/report', [\App\Http\Controllers\User\AccountController::class, 'balance_log_report']);
        Route::post('settings/whitelist-ip', [\App\Http\Controllers\User\AccountController::class, 'postSettingsWhitelistIP']);
        Route::get('settings', [\App\Http\Controllers\User\AccountController::class, 'getSettings']);
        Route::patch('settings', [\App\Http\Controllers\User\AccountController::class, 'postSettings']);
        Route::get('settings/notification/{type}/{value}', [\App\Http\Controllers\User\AccountController::class, 'setNotification']);
    });
    Route::group(['prefix' => 'deposit'], function() {
        Route::get('new', [\App\Http\Controllers\User\DepositController::class, 'getNew']);
        Route::post('new', [\App\Http\Controllers\User\DepositController::class, 'postNew']);
        Route::get('history', [\App\Http\Controllers\User\DepositController::class, 'history']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\User\DepositController::class, 'detail']);
        Route::get('report', [\App\Http\Controllers\User\DepositController::class, 'report']);
    });
    Route::group(['prefix' => 'order'], function() {
        Route::get('single', [\App\Http\Controllers\User\Order\SingleController::class, 'get']);
        Route::post('single', [\App\Http\Controllers\User\Order\SingleController::class, 'post']);
        Route::get('bulk', [\App\Http\Controllers\User\Order\BulkController::class, 'get']);
        Route::post('bulk', [\App\Http\Controllers\User\Order\BulkController::class, 'post']);
        Route::get('new', [\App\Http\Controllers\User\OrderController::class, 'getNew']);
        Route::post('new', [\App\Http\Controllers\User\OrderController::class, 'postNew']);
        Route::get('history', [\App\Http\Controllers\User\OrderController::class, 'history']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\User\OrderController::class, 'detail']);
        Route::get('report', [\App\Http\Controllers\User\OrderController::class, 'report']);
        Route::group(['prefix' => 'refill'], function() {
            Route::get('create/{target:id}', [\App\Http\Controllers\User\OrderRefillController::class, 'create']);
            Route::get('history', [\App\Http\Controllers\User\OrderRefillController::class, 'history']);
            Route::get('detail/{target:id}', [\App\Http\Controllers\User\OrderRefillController::class, 'detail']);
        });
    });
    Route::group(['prefix' => 'ticket'], function() {
        Route::get('list', [\App\Http\Controllers\User\TicketController::class, 'list']);
        Route::get('send', [\App\Http\Controllers\User\TicketController::class, 'getSend']);
        Route::post('send', [\App\Http\Controllers\User\TicketController::class, 'postSend']);
        Route::get('reply/{target:id}', [\App\Http\Controllers\User\TicketController::class, 'getReply']);
        Route::patch('reply/{target:id}', [\App\Http\Controllers\User\TicketController::class, 'postReply']);
    });
    Route::group(['prefix' => 'page'], function() {
        Route::group(['prefix' => 'service'], function() {
            Route::get('list', [\App\Http\Controllers\User\PageController::class, 'service_list'])->withoutMiddleware(['auth']);
            Route::get('monitoring', [\App\Http\Controllers\User\PageController::class, 'monitoring_service']);
            Route::get('detail/{target:id}', [\App\Http\Controllers\User\PageController::class, 'service_detail'])->withoutMiddleware(['auth']);
        });
        Route::get('site/{target:slug}', [\App\Http\Controllers\User\PageController::class, 'site'])->withoutMiddleware(['auth']);
        Route::get('notification', [\App\Http\Controllers\User\PageController::class, 'notification']);
        Route::get('information', [\App\Http\Controllers\User\PageController::class, 'information']);
        Route::get('hof', [\App\Http\Controllers\User\PageController::class, 'hof']);
        Route::get('api_doc', [\App\Http\Controllers\User\PageController::class, 'api_doc']);
    });
});