<?php

use App\Http\Controllers\Api\EsgController;
use App\Http\Controllers\Api\HistoryController;
use App\Http\Controllers\Api\HomePageController;
use App\Http\Controllers\Api\NewsController;
use App\Http\Controllers\Api\ProfilePageController;
use App\Http\Controllers\Api\ProjectController;
use App\Http\Controllers\Api\AlbumController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');
Route::post('/post-test', function (Request $request) {
    return response()->json(['message' => 'Sample post test endpoint']);
});

Route::prefix('{locale}')->group(function (){
    Route::prefix('histories')->group(function (){
        Route::get('/', [HistoryController::class, 'list']);
    });
    Route::prefix('home')->group(function (){
        Route::get('/news', [HomePageController::class, 'list']);
        Route::get('/banners', [HomePageController::class, 'banners']);
    });

    Route::prefix('profile')->group(function () {
        Route::get('/', [ProfilePageController::class, 'list']);
    });

    Route::prefix('news')->group(function (){
        Route::get('/', [NewsController::class, 'list']);
        Route::get('/{id}', [NewsController::class, 'detail'])->whereIn('locale', ["tw", "en"])->where('id', '[0-9]+');
    });

    Route::prefix('project')->group(function () {
        Route::get('/', [ProjectController::class, 'list']);
        Route::get('/{id}', [ProjectController::class, 'detail'])->whereIn('locale', ["tw", "en"])->where('id', '[0-9]+');
        Route::get('/badges', [ProjectController::class, 'badges']);
    });
    Route::prefix('album')->group(function (){
        Route::get('/list', [AlbumController::class, 'list']);
    });

    Route::prefix("esg")->group(function () {
        Route::get("/histories", [EsgController::class, 'histories']);
        Route::get("/upload-files", [EsgController::class, "uploadFiles"]);
    });
});
