<?php

use App\Modules\HR\Organization\Controllers\BranchPageController;
use App\Modules\HR\Organization\Controllers\CostCenterPageController;
use App\Modules\HR\Organization\Controllers\JobGradePageController;
use App\Modules\HR\Organization\Controllers\SectionPageController;
use App\Modules\HR\Organization\Controllers\TeamPageController;
use App\Modules\HR\Organization\Controllers\WorkLocationPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/branches')->name('hr.branches.')->middleware('module:hr')->group(function () {
    Route::get('/', [BranchPageController::class, 'index'])->middleware('can:branchs.view')->name('index');
    Route::get('/create', [BranchPageController::class, 'create'])->middleware('can:branchs.create')->name('create');
    Route::post('/', [BranchPageController::class, 'store'])->middleware('can:branchs.create')->name('store');
    Route::get('/{branch}/edit', [BranchPageController::class, 'edit'])->middleware('can:branchs.update,branch')->name('edit');
    Route::put('/{branch}', [BranchPageController::class, 'update'])->middleware('can:branchs.update,branch')->name('update');
    Route::post('/{branch}/deactivate', [BranchPageController::class, 'deactivate'])->middleware('can:branchs.deactivate,branch')->name('deactivate');
});

Route::prefix('hr/sections')->name('hr.sections.')->middleware('module:hr')->group(function () {
    Route::get('/', [SectionPageController::class, 'index'])->middleware('can:sections.view')->name('index');
    Route::get('/create', [SectionPageController::class, 'create'])->middleware('can:sections.create')->name('create');
    Route::post('/', [SectionPageController::class, 'store'])->middleware('can:sections.create')->name('store');
    Route::get('/{section}/edit', [SectionPageController::class, 'edit'])->middleware('can:sections.update,section')->name('edit');
    Route::put('/{section}', [SectionPageController::class, 'update'])->middleware('can:sections.update,section')->name('update');
    Route::post('/{section}/deactivate', [SectionPageController::class, 'deactivate'])->middleware('can:sections.deactivate,section')->name('deactivate');
});

Route::prefix('hr/teams')->name('hr.teams.')->middleware('module:hr')->group(function () {
    Route::get('/', [TeamPageController::class, 'index'])->middleware('can:teams.view')->name('index');
    Route::get('/create', [TeamPageController::class, 'create'])->middleware('can:teams.create')->name('create');
    Route::post('/', [TeamPageController::class, 'store'])->middleware('can:teams.create')->name('store');
    Route::get('/{team}/edit', [TeamPageController::class, 'edit'])->middleware('can:teams.update,team')->name('edit');
    Route::put('/{team}', [TeamPageController::class, 'update'])->middleware('can:teams.update,team')->name('update');
    Route::post('/{team}/deactivate', [TeamPageController::class, 'deactivate'])->middleware('can:teams.deactivate,team')->name('deactivate');
});

Route::prefix('hr/job-grades')->name('hr.job-grades.')->middleware('module:hr')->group(function () {
    Route::get('/', [JobGradePageController::class, 'index'])->middleware('can:job_grades.view')->name('index');
    Route::get('/create', [JobGradePageController::class, 'create'])->middleware('can:job_grades.create')->name('create');
    Route::post('/', [JobGradePageController::class, 'store'])->middleware('can:job_grades.create')->name('store');
    Route::get('/{job_grade}/edit', [JobGradePageController::class, 'edit'])->middleware('can:job_grades.update,job_grade')->name('edit');
    Route::put('/{job_grade}', [JobGradePageController::class, 'update'])->middleware('can:job_grades.update,job_grade')->name('update');
    Route::post('/{job_grade}/deactivate', [JobGradePageController::class, 'deactivate'])->middleware('can:job_grades.deactivate,job_grade')->name('deactivate');
});

Route::prefix('hr/work-locations')->name('hr.work-locations.')->middleware('module:hr')->group(function () {
    Route::get('/', [WorkLocationPageController::class, 'index'])->middleware('can:work_locations.view')->name('index');
    Route::get('/create', [WorkLocationPageController::class, 'create'])->middleware('can:work_locations.create')->name('create');
    Route::post('/', [WorkLocationPageController::class, 'store'])->middleware('can:work_locations.create')->name('store');
    Route::get('/{work_location}/edit', [WorkLocationPageController::class, 'edit'])->middleware('can:work_locations.update,work_location')->name('edit');
    Route::put('/{work_location}', [WorkLocationPageController::class, 'update'])->middleware('can:work_locations.update,work_location')->name('update');
    Route::post('/{work_location}/deactivate', [WorkLocationPageController::class, 'deactivate'])->middleware('can:work_locations.deactivate,work_location')->name('deactivate');
});

Route::prefix('hr/cost-centers')->name('hr.cost-centers.')->middleware('module:hr')->group(function () {
    Route::get('/', [CostCenterPageController::class, 'index'])->middleware('can:cost_centers.view')->name('index');
    Route::get('/create', [CostCenterPageController::class, 'create'])->middleware('can:cost_centers.create')->name('create');
    Route::post('/', [CostCenterPageController::class, 'store'])->middleware('can:cost_centers.create')->name('store');
    Route::get('/{cost_center}/edit', [CostCenterPageController::class, 'edit'])->middleware('can:cost_centers.update,cost_center')->name('edit');
    Route::put('/{cost_center}', [CostCenterPageController::class, 'update'])->middleware('can:cost_centers.update,cost_center')->name('update');
    Route::post('/{cost_center}/deactivate', [CostCenterPageController::class, 'deactivate'])->middleware('can:cost_centers.deactivate,cost_center')->name('deactivate');
});
