<?php

use App\Http\Controllers\AccountController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\SupportController as AdminSupportController;
use App\Http\Controllers\Admin\TransactionController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\HisaController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ReceiveController;
use App\Http\Controllers\SendController;
use App\Http\Controllers\SupportController;
use App\Http\Controllers\TransferController;
use Illuminate\Support\Facades\Route;

Route::get('/', [HomeController::class, 'index'])->name('home');

Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/login', [LoginController::class, 'login']);
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');

Route::get('/register', [RegisterController::class, 'showRegistrationForm'])->name('register');
Route::post('/register', [RegisterController::class, 'register']);

Route::middleware('auth')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/dashboard/account', [AccountController::class, 'index'])->name('account');
    Route::post('/account/upgrade', [AccountController::class, 'upgrade'])->name('account.upgrade');
    Route::get('/dashboard/hisa', [HisaController::class, 'index'])->name('hisa');
    Route::get('/dashboard/profile', [ProfileController::class, 'index'])->name('profile');
    Route::put('/dashboard/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::get('/dashboard/receive', [ReceiveController::class, 'index'])->name('receive');
    Route::get('/dashboard/send', [SendController::class, 'index'])->name('send');
    Route::post('/dashboard/send', [SendController::class, 'store'])->name('send.store');
    Route::get('/dashboard/support', [SupportController::class, 'index'])->name('support');
    Route::post('/dashboard/support', [SupportController::class, 'store'])->name('support.store');
    Route::get('/dashboard/transfers', [TransferController::class, 'index'])->name('transfers');

    Route::middleware('admin')->prefix('admin')->name('admin.')->group(function () {
        Route::get('/', [AdminController::class, 'index'])->name('index');
        Route::get('/users', [UserController::class, 'index'])->name('users');
        Route::put('/users/{user}', [UserController::class, 'update'])->name('users.update');
        Route::get('/transactions', [TransactionController::class, 'index'])->name('transactions');
        Route::get('/support', [AdminSupportController::class, 'index'])->name('support');
        Route::put('/support/{ticket}', [AdminSupportController::class, 'update'])->name('support.update');
    });
});
