<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Secretary\AuthController;
use App\Http\Controllers\Secretary\DashboardController;
use App\Http\Controllers\Secretary\PatientController;
use App\Http\Controllers\Secretary\QueueController;

Route::prefix('secretary')->name('secretary.')->group(function () {

    Route::get('login',  [AuthController::class, 'showLogin'])->name('login');
    Route::post('login', [AuthController::class, 'login'])->name('login.post');

    Route::middleware('secretary.auth')->group(function () {

        Route::post('logout', [AuthController::class, 'logout'])->name('secretary.logout');
        Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

        // بحث AJAX
        Route::get('patients/search', [PatientController::class, 'search'])->name('patients.search');

        // المرضى
        Route::get('patients',           [PatientController::class, 'index'])->name('patients.index');
        Route::get('patients/create',    [PatientController::class, 'create'])->name('patients.create');
        Route::post('patients',          [PatientController::class, 'store'])->name('patients.store');
        Route::get('patients/{id}',      [PatientController::class, 'show'])->name('patients.show');
        Route::get('patients/{id}/edit', [PatientController::class, 'edit'])->name('patients.edit');
        Route::put('patients/{id}',      [PatientController::class, 'update'])->name('patients.update');

        // الطابور
        Route::get('queue',                  [QueueController::class, 'index'])->name('queue.index');
        Route::post('queue/add/{patientId}', [QueueController::class, 'addToQueue'])->name('queue.add');
        Route::patch('queue/{id}/status',    [QueueController::class, 'updateStatus'])->name('queue.status');
        Route::delete('queue/{id}',          [QueueController::class, 'remove'])->name('queue.remove');
    });
});
