<?php

use App\Http\Controllers\Portal\AuthController;
use App\Http\Controllers\Portal\BranchController;
use App\Http\Controllers\Portal\CategoryController;
use App\Http\Controllers\Portal\DashboardController;
use App\Http\Controllers\Portal\DealController;
use App\Http\Controllers\Portal\ItemController;
use App\Http\Controllers\Portal\SettingsController;
use App\Http\Controllers\Portal\StaffController;
use App\Http\Controllers\Portal\TableAreaController;
use App\Http\Controllers\Portal\TableController;
use Illuminate\Support\Facades\Route;

Route::name('portal.')->group(function () {
    Route::get('login', [AuthController::class, 'login'])->name('login');
    Route::post('login', [AuthController::class, 'authenticate']);
    Route::post('logout', [AuthController::class, 'logout'])->name('logout');

    Route::middleware(['auth'])->group(function () {
        Route::get('select-branch', [BranchController::class, 'select'])->name('branches.select');
        Route::post('select-branch', [BranchController::class, 'update'])->name('branches.update');

        Route::middleware(['client.portal'])->group(function () {
            Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');

            Route::get('settings', [SettingsController::class, 'edit'])->name('settings.edit');
            Route::patch('settings/profile', [SettingsController::class, 'updateProfile'])->name('settings.profile.update');
            Route::patch('settings/password', [SettingsController::class, 'updatePassword'])->name('settings.password.update');
            Route::post('settings/2fa', [SettingsController::class, 'enable2fa'])->name('settings.2fa.enable');
            Route::delete('settings/2fa', [SettingsController::class, 'disable2fa'])->name('settings.2fa.disable');

            Route::resource('categories', CategoryController::class);
            Route::resource('table-areas', TableAreaController::class);
            Route::resource('tables', TableController::class);
            Route::resource('items', ItemController::class);
            Route::resource('staff', StaffController::class);
            Route::resource('deals', DealController::class);
        });
    });
});
