<?php

use App\Http\Controllers\HomeController;
use App\Http\Controllers\LeadController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    $locale = session('locale', 'ro');

    return redirect("/{$locale}");
});

Route::get('/sitemap.xml', function () {
    $locales = ['ro', 'ru', 'en', 'it'];

    return response()
        ->view('sitemap', [
            'locales' => $locales,
            'lastmod' => now()->toDateString(),
        ])
        ->header('Content-Type', 'application/xml');
});

Route::prefix('{locale}')
    ->whereIn('locale', ['ro', 'ru', 'en', 'it'])
    ->group(function () {
        Route::get('/', [HomeController::class, 'index'])->name('home');
        Route::get('/thank-you', [HomeController::class, 'thankYou'])->name('thank-you');
        Route::post('/leads', [LeadController::class, 'store'])->name('leads.store');
    });
