<?php

use App\Http\Controllers\Admin\LanguageController;
use App\Http\Controllers\LocaleController;
use Illuminate\Support\Facades\Route;

Route::post('/locale', LocaleController::class)->name('locale.switch');

Route::middleware('auth')->group(function (): void {
    Route::prefix('admin')->name('admin.')->middleware('permission:system.settings.manage')->group(function (): void {
        Route::get('/languages', [LanguageController::class, 'index'])->name('languages.index');
        Route::post('/languages', [LanguageController::class, 'store'])->name('languages.store');
        Route::get('/languages/{language}/edit', [LanguageController::class, 'edit'])->name('languages.edit');
        Route::put('/languages/{language}', [LanguageController::class, 'update'])->name('languages.update');
        Route::delete('/languages/{language}', [LanguageController::class, 'destroy'])->name('languages.destroy');
        Route::post('/languages/{language}/default', [LanguageController::class, 'makeDefault'])->name('languages.default');
        Route::get('/languages/{language}/translations', [LanguageController::class, 'translations'])->name('languages.translations');
        Route::put('/languages/{language}/translations', [LanguageController::class, 'updateTranslations'])->name('languages.translations.update');
        Route::post('/languages/{language}/translations', [LanguageController::class, 'storeTranslation'])->name('languages.translations.store');
    });
});
