<?php

/**
 * Crew Routes — Crew Portal (Authenticated)
 *
 * This file registers all routes for the Crew portal.
 * Routes are populated in Sprint 1 (Auth) and Sprint 6 (Check-in).
 *
 * All crew routes share the prefix /app/crew and require:
 *   - AuthMiddleware      → valid session
 *   - RoleMiddleware      → role = 'crew'
 *   - WorkspaceMiddleware → workspace_id validated
 *
 * Available variable: $router (App\Core\Router instance)
 *
 * Routes to be defined here (for reference — NOT yet registered):
 *
 *   [CHECKIN] — Sprint 6
 *   GET  /app/crew/checkin               CrewCheckinController@index
 *   POST /app/crew/checkin/{guest_code}  CrewCheckinController@checkin
 *   GET  /app/crew/guests/{id}           CrewGuestController@show
 *
 * @package Inveetaire
 * @ref     DBP v1.0 Ch.5, SAD v1.1 Ch.4, INIT-007
 */

// Crew Hub routes group (does NOT run WorkspaceMiddleware)
$router->group('/app/crew', function ($router) {
    $router->get('/home', 'App\\Modules\\Operation\\CrewHomeController@index');
    $router->get('/dashboard', 'App\\Modules\\Operation\\CrewHomeController@dashboard');
    $router->get('/weddings', 'App\\Modules\\Operation\\CrewHomeController@weddingsList');
    $router->post('/select-workspace', 'App\\Modules\\Operation\\CrewHomeController@selectWorkspace', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
}, [
    'App\Middleware\AuthMiddleware',
    'App\Middleware\RoleMiddleware',
]);

// Route group for the Crew portal.
// All crew portal routes inherit Auth, Role, and Workspace boundary middlewares.
$router->group('/app/crew', function ($router) {
    // Load Wedding Operation Suite routes
    require ROOT_PATH . '/app/modules/Operation/routes.php';

    // Load Guest Module routes
    require ROOT_PATH . '/app/modules/Guest/routes.php';

    // Load Guest Engagement Module routes
    require ROOT_PATH . '/app/modules/Engagement/routes.php';

    // Crew Settings Page (Change Password)
    $router->get('/settings', 'App\\Modules\\Auth\\SettingsController@edit');
    $router->post('/settings', 'App\\Modules\\Auth\\SettingsController@update', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
}, [
    'App\Middleware\AuthMiddleware',
    'App\Middleware\RoleMiddleware',
    'App\Middleware\WorkspaceMiddleware',
]);
