<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TransferController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\BalanceRequestController;

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

Route::middleware('auth')->group(function () {
    Route::get('/', [TransferController::class, 'dashboard'])->name('dashboard');
    Route::resource('transfers', TransferController::class);
    Route::resource('balance-requests', BalanceRequestController::class);

    Route::middleware('admin')->group(function () {
        Route::get('/admin/dashboard', [AdminController::class, 'dashboard'])->name('admin.dashboard');
        Route::resource('users', UserController::class)->except(['show']);
        Route::get('users/{user}', [UserController::class, 'show'])->name('users.show');
        Route::patch('users/{user}/balance', [UserController::class, 'updateBalance'])->name('users.balance');
        Route::patch('balance-requests/{balanceRequest}/approve', [BalanceRequestController::class, 'approve'])->name('balance-requests.approve');
        Route::patch('balance-requests/{balanceRequest}/reject', [BalanceRequestController::class, 'reject'])->name('balance-requests.reject');
    });
});
