<?php

use App\Http\Controllers\ContactFormController;
use App\Http\Controllers\Admin\Auth\LoginController;
use App\Http\Middleware\EnsureAdminUserIsActive;
use App\Http\Controllers\PublicPageController;
use Illuminate\Support\Facades\Route;

Route::get('/', [PublicPageController::class, 'home'])->name('home');
Route::get('/a-propos', [PublicPageController::class, 'about'])->name('about');
Route::get('/services', [PublicPageController::class, 'services'])->name('services');
Route::get('/galerie', [PublicPageController::class, 'gallery'])->name('gallery');
Route::get('/contact', [PublicPageController::class, 'contact'])->name('contact');
Route::post('/contact', [ContactFormController::class, 'store'])
    ->middleware('throttle:contact-form')
    ->name('contact.submit');

Route::middleware('guest')->group(function () {
    Route::get('/admin/login', [LoginController::class, 'create'])->name('admin.login');
    Route::post('/admin/login', [LoginController::class, 'store'])->name('admin.login.store');
});

Route::post('/admin/logout', [LoginController::class, 'destroy'])
    ->middleware('auth')
    ->name('admin.logout');

Route::middleware(['auth', EnsureAdminUserIsActive::class])->group(function (): void {
    Route::get('/admin/password/change', [LoginController::class, 'editPassword'])->name('admin.password.edit');
    Route::patch('/admin/password', [LoginController::class, 'updatePassword'])->name('admin.password.update');
});

require __DIR__.'/admin.php';
