<?php 

use Illuminate\Support\Facades\Route;
use Portal\Mileage\Http\Controllers\ApplyformController;
use Portal\Mileage\Http\Controllers\ApplicationsController;
use Portal\Mileage\Http\Controllers\ProjectManagerController;
use Portal\Mileage\Http\Controllers\ProjectDirectorController;

Route::group(
    [
        'prefix'     => '',
        'as'         => 'mileage::',
        'middleware' => ['web', 'auth'],
    ],
    function () {
        // Applyform
        Route::resource('applyform', ApplyformController::class);

        // Applications
        Route::resource('applications', ApplicationsController::class);
        Route::put('applications/{id}/updateStatus', [ApplicationsController::class, 'updateStatus'])
            ->name('applications.updateStatus');

        // Project Manager
        Route::prefix('projectManager')->name('projectManager.')->group(function () {
            Route::get('/', [ProjectManagerController::class, 'index'])->name('index'); 
            Route::get('/show/{id}', [ProjectManagerController::class, 'show'])->name('show');
        });

        // Project Director
        Route::prefix('projectDirector')->name('projectDirector.')->group(function () {
            Route::get('/dashboard', [ProjectDirectorController::class, 'index'])->name('index');
            Route::get('/show/{id}', [ProjectDirectorController::class, 'show'])->name('show');
            Route::post('/{id}/approve', [ProjectDirectorController::class, 'approve'])->name('approve');
            Route::post('/{id}/reject', [ProjectDirectorController::class, 'reject'])->name('reject');
        });
    }
);

// Guest group (currently unused)
Route::group(
    [
        'prefix'     => '',
        'as'         => 'mileage::',
        'middleware' => ['guest'],
    ],
    function () {
        //
    }
);
