<?php

use App\Modules\HR\Offboarding\Controllers\OffboardingController;
use App\Modules\HR\Offboarding\Models\OffboardingCase;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/offboarding')->name('hr.offboarding.')->middleware('module:hr')->group(function (): void {
    Route::get('/', [OffboardingController::class, 'index'])->middleware('can:offboarding.view')->name('index');
    Route::post('/', [OffboardingController::class, 'store'])->middleware('can:offboarding.create')->name('store');
    Route::get('/{case}', [OffboardingController::class, 'show'])->middleware('can:view,case')->name('show');
    Route::put('/{case}', [OffboardingController::class, 'update'])->middleware('can:update,case')->name('update');
    Route::post('/{case}/checklist', [OffboardingController::class, 'addChecklistItem'])
        ->middleware('can:manage,case')->name('checklist.store');
    foreach (['submit', 'approve', 'clearance', 'final-settlement', 'complete'] as $action) {
        Route::post('/{case}/'.$action, fn (OffboardingController $controller, OffboardingCase $case) => $controller->action($case, $action))
            ->middleware('can:manage,case')->name($action);
    }
});
