<?php

use App\Modules\HR\Shifts\Controllers\EmployeeShiftAssignmentPageController;
use App\Modules\HR\Shifts\Controllers\ShiftPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/shifts')->name('hr.shifts.')->middleware('module:hr')->group(function () {
    Route::get('/', [ShiftPageController::class, 'index'])
        ->middleware('can:shifts.view')
        ->name('index');

    Route::get('/create', [ShiftPageController::class, 'create'])
        ->middleware('can:shifts.create')
        ->name('create');

    Route::post('/', [ShiftPageController::class, 'store'])
        ->middleware('can:shifts.create')
        ->name('store');

    Route::get('/assignments/create', [EmployeeShiftAssignmentPageController::class, 'create'])
        ->middleware('can:shifts.assign')
        ->name('assignments.create');

    Route::post('/assignments', [EmployeeShiftAssignmentPageController::class, 'store'])
        ->middleware('can:shifts.assign')
        ->name('assignments.store');

    Route::get('/{shift}/edit', [ShiftPageController::class, 'edit'])
        ->middleware('can:shifts.update,shift')
        ->name('edit');

    Route::put('/{shift}', [ShiftPageController::class, 'update'])
        ->middleware('can:shifts.update,shift')
        ->name('update');

    Route::post('/{shift}/deactivate', [ShiftPageController::class, 'deactivate'])
        ->middleware('can:shifts.deactivate,shift')
        ->name('deactivate');
});
