<?php

use App\Http\Controllers\ProfileController;
use App\Modules\Admin\Operations\Controllers\SupportImpersonationEndController;
use App\Modules\Settings\Rbac\Controllers\InvitationAcceptController;
use Illuminate\Support\Facades\Route;

require base_path('app/Modules/HR/Recruitment/Routes/career-portal.php');

Route::middleware(['web', 'guest'])->group(function () {
    Route::get('/invite/accept/{token}', [InvitationAcceptController::class, 'show'])
        ->name('settings.users.invite.accept');

    Route::post('/invite/accept/{token}', [InvitationAcceptController::class, 'store'])
        ->name('settings.users.invite.accept.store');
});

Route::get('/', function () {
    return view('welcome');
});

require base_path('app/Modules/Dashboard/Routes/web.php');
require base_path('app/Modules/Exports/Routes/web.php');

Route::get('/ui-kit', function () {
    return view('ui-kit');
})->middleware('auth')->name('ui-kit');

Route::middleware(['auth', 'tenant.lifecycle', 'subscription.writable'])->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

Route::middleware(['web', 'auth', 'verified', 'tenant.lifecycle', 'subscription.writable', 'employee.self'])
    ->prefix('me')
    ->name('me.')
    ->group(function () {
        require base_path('app/Modules/HR/EmployeeSelfService/Routes/web.php');
    });

Route::middleware(['web', 'auth', 'tenant.lifecycle', 'subscription.writable'])->group(function () {
    require base_path('app/Modules/HR/Dashboard/Routes/web.php');
    require base_path('app/Modules/HR/Departments/Routes/web.php');
    require base_path('app/Modules/HR/Departments/Routes/api.php');
    require base_path('app/Modules/HR/Positions/Routes/web.php');
    require base_path('app/Modules/HR/EmploymentStatuses/Routes/web.php');
    require base_path('app/Modules/HR/Organization/Routes/web.php');
    require base_path('app/Modules/HR/Employees/Routes/web.php');
    require base_path('app/Modules/HR/Attendance/Routes/web.php');
    require base_path('app/Modules/HR/Leave/Routes/web.php');
    require base_path('app/Modules/HR/PermissionRequests/Routes/web.php');
    require base_path('app/Modules/HR/Overtime/Routes/web.php');
    require base_path('app/Modules/HR/Contracts/Routes/web.php');
    require base_path('app/Modules/HR/Assets/Routes/web.php');
    require base_path('app/Modules/HR/Loans/Routes/web.php');
    require base_path('app/Modules/HR/Compensation/Routes/web.php');
    require base_path('app/Modules/HR/Performance/Routes/web.php');
    require base_path('app/Modules/HR/Training/Routes/web.php');
    require base_path('app/Modules/HR/Offboarding/Routes/web.php');
    require base_path('app/Modules/HR/Reports/Routes/web.php');
    require base_path('app/Modules/HR/Analytics/Routes/web.php');
    require base_path('app/Modules/HR/Recruitment/Routes/web.php');
    require base_path('app/Modules/HR/Shifts/Routes/web.php');
    require base_path('app/Modules/Payroll/Routes/web.php');
    require base_path('app/Modules/Settings/Localization/Routes/web.php');
    require base_path('app/Modules/Settings/Rbac/Routes/web.php');
    require base_path('app/Modules/Customization/CustomFields/Routes/web.php');
    require base_path('app/Modules/Admin/Tenancy/Routes/web.php');
    require base_path('app/Modules/Inventory/Routes/web.php');
    require base_path('app/Modules/Procurement/Routes/web.php');
    require base_path('app/Modules/Sales/Routes/web.php');
    require base_path('app/Modules/Operations/Routes/web.php');
    require base_path('app/Modules/Platform/Lookup/Routes/web.php');
    require base_path('app/Modules/Platform/Geography/Routes/web.php');
});

require base_path('app/Modules/Settings/Onboarding/Routes/web.php');

Route::middleware(['web', 'auth', 'tenant.lifecycle'])->group(function (): void {
    Route::post('/support/impersonation/end', [SupportImpersonationEndController::class, 'store'])
        ->name('support.impersonation.end');
});

require __DIR__.'/auth.php';
