<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\DiagnoseController;
use App\Http\Controllers\Patients\PatientController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
*/

// Authentication Routes
Route::get('/auth_user/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/auth_user/login', [LoginController::class, 'login']);
Route::post('/auth_user/logout', [LoginController::class, 'logout'])->name('logout');

// Home route
Route::get('/', function () {
    return redirect()->route('patients.index');
});

// Patients Routes
Route::prefix('patients')->name('patients.')->group(function () {
    Route::get('/', [PatientController::class, 'index'])->name('index');
    Route::get('/show/{id}', [PatientController::class, 'show'])->name('show');
    Route::get('/create', [PatientController::class, 'create'])->name('create');
    Route::post('/create', [PatientController::class, 'store'])->name('store');
    Route::get('/edit/{id}', [PatientController::class, 'edit'])->name('edit');
    Route::put('/edit/{id}', [PatientController::class, 'update'])->name('update');
    Route::delete('/delete/{id}', [PatientController::class, 'destroy'])->name('destroy');
});

// Diagnose Routes
Route::prefix('diagnose')->name('diagnose.')->group(function () {
    Route::get('/clinical', [DiagnoseController::class, 'clinical'])->name('clinical');
    Route::post('/clinical', [DiagnoseController::class, 'clinicalStore'])->name('clinical.store');
    
    Route::get('/scan', [DiagnoseController::class, 'scan'])->name('scan');
    Route::post('/scan', [DiagnoseController::class, 'scanStore'])->name('scan.store');
    
    Route::get('/result', [DiagnoseController::class, 'result'])->name('result');
    Route::post('/result', [DiagnoseController::class, 'resultStore'])->name('result.store');
});

// Admin route
Route::get('/admin', function () {
    return view('admin.dashboard');
})->middleware(['auth', 'admin'])->name('admin.dashboard');