<?php

use App\Http\Controllers\Auth\AuthenticatedSessionController;
use Illuminate\Support\Facades\Route;

// Page d'accueil - redirige vers le dashboard
Route::get('/', function () {
    return redirect()->route('dashboard');
});

// Routes d'authentification (accessibles sans être connecté)
Route::middleware('guest')->group(function () {
    Route::get('/login', [AuthenticatedSessionController::class, 'create'])->name('login');
    Route::post('/login', [AuthenticatedSessionController::class, 'store']);
});

// Déconnexion
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');

// Routes protégées (nécessitent une authentification)
Route::middleware(['auth'])->group(function () {
    // Dashboard
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');

    // Produits
    Route::get('/products', function () {
        return view('products.index');
    })->name('products.index');

    // Stocks
    Route::get('/stocks', function () {
        return view('stocks.index');
    })->name('stocks.index');

    // Mouvements
    Route::get('/movements', function () {
        return view('movements.index');
    })->name('movements.index');

    // Demandes
    Route::get('/requests', function () {
        return view('requests.index');
    })->name('requests.index');

    // Catégories
    Route::get('/categories', function () {
        return view('categories.index');
    })->name('categories.index');

    // Départements
    Route::get('/departments', function () {
        return view('departments.index');
    })->name('departments.index');

    // Fournisseurs
    Route::get('/suppliers', function () {
        return view('suppliers.index');
    })->name('suppliers.index');

    // Unités
    Route::get('/units', function () {
        return view('units.index');
    })->name('units.index');

    // Équipements
    Route::get('/equipment', function () {
        return view('equipment.index');
    })->name('equipment.index');
});
