<?php

use App\Modules\HR\Contracts\Controllers\ContractTemplateController;
use App\Modules\HR\Contracts\Controllers\EmploymentContractsPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/contracts')
    ->name('hr.contracts.')
    ->middleware('module:hr')
    ->group(function () {
        Route::get('/', [EmploymentContractsPageController::class, 'index'])
            ->middleware('can:contracts.view')
            ->name('index');
        Route::get('/create', [EmploymentContractsPageController::class, 'create'])
            ->middleware('can:contracts.create')
            ->name('create');
        Route::post('/', [EmploymentContractsPageController::class, 'store'])
            ->middleware('can:contracts.create')
            ->name('store');
        Route::get('/{employment_contract}/edit', [EmploymentContractsPageController::class, 'edit'])
            ->middleware('can:contracts.update,employment_contract')
            ->name('edit');
        Route::put('/{employment_contract}', [EmploymentContractsPageController::class, 'update'])
            ->middleware('can:contracts.update,employment_contract')
            ->name('update');
        Route::post('/{employment_contract}/deactivate', [EmploymentContractsPageController::class, 'deactivate'])
            ->middleware('can:contracts.deactivate,employment_contract')
            ->name('deactivate');
        Route::post('/{employment_contract}/amend', [EmploymentContractsPageController::class, 'amend'])
            ->middleware('can:contracts.update,employment_contract')->name('amend');
        Route::post('/{employment_contract}/renew', [EmploymentContractsPageController::class, 'renew'])
            ->middleware('can:contracts.update,employment_contract')->name('renew');
        Route::post('/{employment_contract}/terminate', [EmploymentContractsPageController::class, 'terminate'])
            ->middleware('can:contracts.deactivate,employment_contract')->name('terminate');
    });

Route::prefix('hr/contract-templates')->name('hr.contract-templates.')
    ->middleware(['module:hr', 'can:contract_templates.manage'])->group(function (): void {
        Route::get('/', [ContractTemplateController::class, 'index'])->name('index');
        Route::get('/create', [ContractTemplateController::class, 'create'])->name('create');
        Route::post('/', [ContractTemplateController::class, 'store'])->name('store');
        Route::get('/{contract_template}/edit', [ContractTemplateController::class, 'edit'])->name('edit');
        Route::put('/{contract_template}', [ContractTemplateController::class, 'update'])->name('update');
    });
