<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ClientesController;
use App\Http\Controllers\UsuariosController;
use App\Http\Controllers\VendedoresController;
use App\Http\Controllers\OrdenCompraController;
use App\Http\Controllers\Auth\AuthenticatedSessionController;

Route::get('/', [AuthenticatedSessionController::class, 'create']);

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

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::prefix("Proformas")->controller(OrdenCompraController::class)->group(function () {
        Route::get("/", "index")->name("proformas.index");
        Route::get("/generarPDF/{id_orden}", "generarPDF")->name("proformas.generarPDF");
        Route::get("/listas", "ocLista")->name("proformas.listas");
    });

    Route::prefix("Usuarios")->controller(UsuariosController::class)->group(function () {
        Route::get("/", "index")->name("usuarios.index");
        Route::post("/store", "store")->name("usuarios.store");
        Route::post("/bajaUser", "bajaUser")->name("usuarios.bajaUser");
    });

    Route::prefix("Vendedores")->controller(VendedoresController::class)->group(function () {
        Route::get("/", "index")->name("vendedores.index");
    });

    Route::prefix("Clientes")->controller(ClientesController::class)->group(function () {
        Route::get("/", "index")->name("clientes.index");
        Route::post("/store", "store")->name("clientes.store");
        Route::post("/obtenerClientesDT", "obtenerClientesDT")->name("clientes.obtenerClientesDT");
        Route::get("/obtenerClientesById/{id}", "obtenerClientesById")->name("clientes.obtenerClientesById");
    });
});



require __DIR__.'/auth.php';
