<?php

use App\Http\Controllers\ContactController;
use App\Http\Controllers\PageController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\SitemapController;
use App\Http\Middleware\PreventRequestForgeryWithoutCookie;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Route;
use Illuminate\View\Middleware\ShareErrorsFromSession;

/*
| Pages d'information : aucune session, donc aucun cookie.
| Seule la page Contact ouvre une session (jeton du formulaire, message de retour).
*/
Route::withoutMiddleware([
    StartSession::class,
    ShareErrorsFromSession::class,
    PreventRequestForgeryWithoutCookie::class,
])->group(function () {
    Route::get('/', [PageController::class, 'home'])->name('home');
    Route::get('/produits', [ProductController::class, 'index'])->name('products.index');
    Route::get('/produits/{product}', [ProductController::class, 'show'])
        ->where('product', '[a-z0-9-]+')
        ->name('products.show');
    Route::get('/societe', [PageController::class, 'company'])->name('company');
    Route::get('/mentions-legales', [PageController::class, 'legalNotice'])->name('legal.notice');
    Route::get('/confidentialite', [PageController::class, 'privacy'])->name('legal.privacy');
    Route::get('/sitemap.xml', [SitemapController::class, 'sitemap'])->name('sitemap');
    Route::get('/robots.txt', [SitemapController::class, 'robots'])->name('robots');
});

Route::get('/contact', [ContactController::class, 'show'])->name('contact');
Route::post('/contact', [ContactController::class, 'send'])
    ->middleware('throttle:contact')
    ->name('contact.send');
