<?php

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 Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');


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::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}', [NewsController::class, 'detail'])->whereIn('locale', ["tw", "en"])->where('id', '[0-9]+');
        Route::get('/badges', [ProjectController::class, 'badges']);
    });
});
