<?php

use App\Http\Controllers\BookingController;
use App\Http\Controllers\CekStatusController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\DataSoalController;
use App\Http\Controllers\FinishUjianController;
use App\Http\Controllers\HalamanUjianController;
use App\Http\Controllers\HasilTesController;
use App\Http\Controllers\LandingController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\TestSessionsController;
use App\Http\Controllers\TobiiReceiverController;
use App\Http\Controllers\TutorialTesController;
use App\Http\Controllers\UsersController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return redirect('/beranda');
});

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

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

Route::resource('beranda', LandingController::class)->only(['index']);
    Route::get('/about', [LandingController::class, 'about'])->name('beranda.about');
Route::resource('booking', BookingController::class)->only(['store']);
Route::resource('cek-status', CekStatusController::class)->only(['index', 'show']);
Route::resource('tutorial-tes', TutorialTesController::class)->only(['index']);
Route::resource('test-sessions', TestSessionsController::class)->only(['store', 'show']);
Route::resource('tobii-receiver', TobiiReceiverController::class)->only(['store', 'show']);
    Route::get('tobii-receiver/fetch/data/{id_test_sessions}', [TobiiReceiverController::class, 'fetchDataTobii'])->name('tobii-receiver.fetchData');
Route::resource('ujian', HalamanUjianController::class);
    Route::get('ujian/get/current-answer', [HalamanUjianController::class, 'getCurrentAnswer'])->name('ujian.getCurrentAnswer');
    Route::get('ujian/get/time-left', [HalamanUjianController::class, 'getTimeLeft'])->name('ujian.getTimeLeft');
    Route::get('ujian/fetch/question', [HalamanUjianController::class, 'fetchQuestion'])->name('ujian.fetchQuestion');
    Route::get('ujian/fetch/navigation-field', [HalamanUjianController::class, 'getNavigationField'])->name('ujian.navigationField');
Route::resource('hasil-tes', FinishUjianController::class)->only(['index', 'show']);
    Route::get('hasil-tes/get/all-answer', [FinishUjianController::class, 'getAllAnswer'])->name('hasil-tes.getAllAnswer');
Route::middleware(['auth', 'role.auth'])->group(function() {
    Route::resource('dashboard', DashboardController::class);
    Route::resource('users', UsersController::class);
        Route::get('users/fetch/data', [UsersController::class, 'getData'])->name('users.fetchData');
    Route::resource('booking', BookingController::class)->except(['store']);
        Route::get('booking/fetch/data', [BookingController::class, 'getchData'])->name('booking.fetchData');
    Route::resource('soal', DataSoalController::class);
        Route::get('soal/fetch/data', [DataSoalController::class, 'getData'])->name('soal.fetchData');
    Route::resource('hasil_tes', HasilTesController::class);
});

Route::get('email/test', function(Request $req) {
    return view('layouts.mail-send-code', [
        'code' => 'ABC123',
        'name' => 'Mahayoga',
        'startExpirationTime' => '09:00:00',
        'endExpirationTime' => '09:05:00',
        'tglExpired' => '2023-10-01'
    ]);
});

require __DIR__.'/auth.php';
