<?php

use App\Http\Controllers\Admin\ClientController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\IndustryController;
use App\Http\Controllers\Admin\PageContentController;
use App\Http\Controllers\Admin\ProjectController;
use App\Http\Controllers\Admin\ServiceController;
use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\LocaleController;
use App\Http\Controllers\PageController;
use Illuminate\Support\Facades\Route;

Route::controller(PageController::class)->group(function () {
    Route::get('/', 'home')->name('home');
    Route::get('/about', 'about')->name('about');
    Route::get('/services', 'services')->name('services');
    Route::get('/industries', 'industries')->name('industries');
    Route::get('/clients', 'clients')->name('clients');
    Route::get('/contact', 'contact')->name('contact');
});

Route::post('/contact', [ContactController::class, 'submit'])->name('contact.submit');
Route::post('/locale/{locale}', [LocaleController::class, 'update'])->name('locale.update');

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

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

Route::prefix('admin')->middleware(['auth', 'admin'])->name('admin.')->group(function () {
    Route::get('/', DashboardController::class)->name('dashboard');
    Route::resource('services', ServiceController::class)->except('show');
    Route::resource('industries', IndustryController::class)->except('show');
    Route::resource('clients', ClientController::class)->except('show');
    Route::get('/projects', [ProjectController::class, 'index'])->name('projects.index');
    Route::delete('/projects/{project}', [ProjectController::class, 'destroy'])->name('projects.destroy');
    Route::get('/home/edit', [PageContentController::class, 'editHome'])->name('home.edit');
    Route::get('/about/edit', [PageContentController::class, 'editAbout'])->name('about.edit');
    Route::get('/pages', [PageContentController::class, 'index'])->name('pages.index');
    Route::get('/pages/{pageContent}/edit', [PageContentController::class, 'edit'])->name('pages.edit');
    Route::put('/pages/{pageContent}', [PageContentController::class, 'update'])->name('pages.update');
});
