<?php

use App\Livewire\Settings\Appearance;
use App\Livewire\Settings\Password;
use App\Livewire\Settings\Profile;
use App\Livewire\FoodOrder;
use App\Livewire\SelectTable;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TypeItemsController;
use App\Http\Controllers\ItemsController;
use App\Http\Controllers\MejaController;

Route::get('/refresh-csrf', function () {
    return response()->json(['csrf_token' => csrf_token()]);
});

// Route::get('/', FoodOrder::class)->name('menu.all');
Route::get('/', function () {
    return redirect()->route('menu.byType', ['typeSlug' => 'makanan']);
})->name('home');
Route::get('/menu', function () {
    return redirect()->route('menu.byType', ['typeSlug' => 'makanan']);
});
Route::get('/menu/{typeSlug?}', FoodOrder::class)->name('menu.byType');
Route::get('/pilih-meja', SelectTable::class)->name('select.table');

Route::view('dashboard', 'dashboard')->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware(['auth'])->group(function () {
    Route::redirect('settings', 'settings/profile');
    Route::redirect('admin', 'dashboard', 301);
    Route::redirect('home', 'dashboard', 301);

    Route::resource('typeitems',TypeItemsController::class);
    Route::resource('items',ItemsController::class);
    Route::resource('tables',MejaController::class);

    Route::get('settings/profile', Profile::class)->name('settings.profile');
    Route::get('settings/password', Password::class)->name('settings.password');
    Route::get('settings/appearance', Appearance::class)->name('settings.appearance');
});

require __DIR__.'/auth.php';
