<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LayananController;

// API Authentication Routes (Token-based)
Route::prefix('auth')->group(function () {
    Route::post('/login', [AuthController::class, 'login']);

    Route::middleware('auth:sanctum')->group(function () {
        Route::get('/me', [AuthController::class, 'me']);
        Route::post('/logout', [AuthController::class, 'logout']);
        Route::post('/logout-all', [AuthController::class, 'logoutAll']);
    });
});

// Public API Routes for Layanan
Route::prefix('layanan')->group(function () {
    Route::get('/data', [LayananController::class, 'getLayananData']);
    Route::get('/wilayah', [LayananController::class, 'getWilayahData']);
    Route::get('/filter', [LayananController::class, 'getFilteredKegiatan']);
    Route::get('/detail/{id}', [LayananController::class, 'getDetailKegiatan']);
    Route::get('/activity/{id}', [LayananController::class, 'getActivityInfo']);
    Route::post('/feedback', [LayananController::class, 'submitFeedback']);
    Route::get('/activity/{id}/stats', [LayananController::class, 'getFeedbackStats']);
});

// Protected API Routes
Route::middleware('auth:sanctum')->group(function () {
    // Dashboard API endpoints
    Route::prefix('dashboard')->group(function () {
        Route::get('/summary', [DashboardController::class, 'apiSummary']);
        Route::get('/pertek', [DashboardController::class, 'apiPertek']);
        Route::get('/rintek', [DashboardController::class, 'apiRintek']);
        Route::get('/amdal', [DashboardController::class, 'apiAmdal']);
        Route::get('/bengkel', [DashboardController::class, 'apiBengkel']);
    });
});
