<?php

declare(strict_types=1);

use App\Http\Controllers\AssetQrController;
use App\Http\Controllers\DashboardController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web routes
|--------------------------------------------------------------------------
|
| Routes are added one module at a time, each in its own file under
| routes/modules. Splitting by module keeps each file short enough to read in
| one screen; a single 400-line web.php is where route definitions go to be
| forgotten.
|
| Everything below the authenticated group carries the standard stack:
|
|     auth            — a session is required
|     active          — a disabled account is signed out on its next request
|     password.change — a temporary password must be replaced before anything else
|
*/

Route::redirect('/', config('ams.auth.home_path'))->name('home');

require __DIR__.'/auth.php';

/*
 | The QR scan landing deliberately skips `password.change`: being handed a
 | physical label to scan has nothing to do with whether your own account
 | currently owes a password change, and there is no reason to make that the
 | first thing a scan runs into.
 */
Route::middleware(['auth', 'active'])
    ->get('/a/{uuid}', [AssetQrController::class, 'scan'])
    ->name('assets.scan');

Route::middleware(['auth', 'active', 'password.change'])->group(function (): void {
    Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');

    require __DIR__.'/modules/masters.php';
    require __DIR__.'/modules/admin.php';
    require __DIR__.'/modules/employees.php';
    require __DIR__.'/modules/assets.php';
    require __DIR__.'/modules/assignments.php';
    require __DIR__.'/modules/imports.php';
    require __DIR__.'/modules/warranty.php';
    require __DIR__.'/modules/reports.php';
    require __DIR__.'/modules/audit.php';
});
