<?php

use App\Http\Livewire\CancelacionController;
use App\Http\Livewire\DashboardController;
use App\Http\Livewire\ImpresoraController;
use App\Http\Livewire\PedidoController;
use App\Http\Livewire\ReporteController;
use App\Http\Livewire\ReportePedidoController;
use App\Http\Livewire\RutaController;
use App\Http\Livewire\UserController;
use App\Http\Livewire\VentaController;
use App\Http\Livewire\VentaEspecialController;
use App\Models\Venta;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

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

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
    'cajaValidate',
    'role:admin|usuario'
])->group(function () {
    Route::get('/venta',VentaController::class)->name('venta');
    Route::get('/venta-especial',VentaEspecialController::class)->name('venta-especial');
    Route::get('/cancelacion',CancelacionController::class)->name('cancelacion');
});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
    'cajaValidate',
    'role:admin|compras|ventas|usuario'
])->group(function (){
    Route::get('/pedido',PedidoController::class)->name('pedido');
});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
    'cajaValidate'
])->group(function(){
    Route::get('/configuracion-impresora',ImpresoraController::class)->name('impresora');

});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
])->get('/dashboard',DashboardController::class)->name('dashboard');

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
    'role:admin'
])->group(function(){
    
    Route::get('/reporte-ventas',ReporteController::class)->name('reporte-ventas');
    Route::get('/rutas',RutaController::class)->name('rutas');
    Route::get('/usuarios',UserController::class)->name('usuarios');
});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
    'role:admin|compras'
])->group(function(){
    Route::get('/reporte-pedidos',ReportePedidoController::class)->name('reporte-pedidos');
});