<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\AuthController;

use App\Http\Controllers\PendaftaranController;
use App\Http\Controllers\LaporanController;
use App\Http\Controllers\AntrianController;
use App\Http\Controllers\DataPasienController;
use App\Http\Controllers\BackUpController;

use App\Http\Controllers\UserController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

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

// Pendaftaran Antrian
Route::group([
    'middleware' => 'auth',
    'prefix' => 'pendaftaran'
], function () {
    Route::get('antrian/{id}', [PendaftaranController::class, 'pendaftaranAntrian']);
    Route::post('antrian/baru', [PendaftaranController::class, 'storeDataPasien']);
    Route::get('antrian/data/{id}', [PendaftaranController::class, 'dataPendaftaranAntrian']);
    Route::put('antrian/pasien/{antrian}', [PendaftaranController::class, 'storePendaftaranAntrian']);
});

Route::group([
    'middleware' => 'auth'
], function () {
    // home
    Route::get('/', [PendaftaranController::class, 'index'])->name('home');

    // Antrian
    Route::get('antrian', [AntrianController::class, 'index']);
    Route::get('antrian/data', [AntrianController::class, 'data']);
    Route::delete('antrianDelete/{antrian}', [AntrianController::class, 'deleteAntrian']);
    Route::put('updateStatusAntrian/{antrian}', [AntrianController::class, 'updateStatusAntrian']);

    // Penanganan Pasien
    Route::get('penangananPasien/{id}', [AntrianController::class, 'penanganan']);
    Route::put('dataPenangananPasien/{antrian}', [AntrianController::class, 'updatePenanganan']);

    // Data Pasien
    Route::resource('data_pasien', DataPasienController::class);

    // Laporan
    Route::get('laporan', [LaporanController::class, 'index']);
    Route::post('laporan', [LaporanController::class, 'index']);

    // Daftar Pengguna
    Route::apiResource('user', UserController::class);

    // Back Up
    Route::get('backup', [BackUpController::class, 'index']);
    Route::post('backup_database', [BackUpController::class, 'backUp'])->name('BackUp');

    Route::get('logout', [AuthController::class, 'logout'])->name('logout');
});
