<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PublicController;
use App\Http\Controllers\Admin\AuthController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\ArticleController as AdminArticleController;
use App\Http\Controllers\Admin\PosterController as AdminPosterController;
use App\Http\Controllers\Admin\VideoController as AdminVideoController;
use App\Http\Controllers\Admin\QuizQuestionController as AdminQuizQuestionController;
use App\Http\Controllers\Admin\StudentScoreController;

/*
|--------------------------------------------------------------------------
| Public Routes (Siswa / Pengunjung Desa - Tanpa Login)
|--------------------------------------------------------------------------
*/
Route::get('/', [PublicController::class, 'home'])->name('home');
Route::get('/jenis-sampah', [PublicController::class, 'jenisSampah'])->name('jenis-sampah');
Route::get('/cara-memilah', [PublicController::class, 'caraMemilah'])->name('cara-memilah');
Route::get('/konsep-3r', [PublicController::class, 'konsep3R'])->name('konsep-3r');
Route::get('/jadwal-lokasi', [PublicController::class, 'jadwalLokasi'])->name('jadwal-lokasi');

Route::get('/artikel', [PublicController::class, 'articles'])->name('articles.index');
Route::get('/artikel/{slug}', [PublicController::class, 'showArticle'])->name('articles.show');

Route::get('/poster', [PublicController::class, 'posters'])->name('posters.index');
Route::get('/poster/{id}/download', [PublicController::class, 'downloadPoster'])->name('posters.download');

Route::get('/video', [PublicController::class, 'videos'])->name('videos.index');

Route::get('/kuis', [PublicController::class, 'quiz'])->name('quiz.index');
Route::post('/kuis/submit-score', [PublicController::class, 'submitScore'])->name('quiz.submit-score');
Route::get('/kuis/leaderboard', [PublicController::class, 'leaderboard'])->name('quiz.leaderboard');


/*
|--------------------------------------------------------------------------
| Admin Auth Routes
|--------------------------------------------------------------------------
*/
Route::get('/lengkong-admin/login', [AuthController::class, 'showLogin'])->name('admin.login');
Route::post('/lengkong-admin/login', [AuthController::class, 'login'])->name('admin.login.submit');
Route::get('/lengkong-admin/register', [AuthController::class, 'showRegister'])->name('admin.register');
Route::post('/lengkong-admin/register', [AuthController::class, 'register'])->name('admin.register.submit');
Route::post('/admin/logout', [AuthController::class, 'logout'])->name('admin.logout');


/*
|--------------------------------------------------------------------------
| Admin Authenticated Panel Routes
|--------------------------------------------------------------------------
*/
Route::middleware('auth')->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

    Route::resource('articles', AdminArticleController::class)->except(['show']);
    Route::resource('posters', AdminPosterController::class)->except(['show', 'edit', 'update']);
    Route::resource('videos', AdminVideoController::class)->except(['show', 'edit', 'update']);
    Route::resource('quiz', AdminQuizQuestionController::class)->parameters(['quiz' => 'quiz'])->except(['show']);
    Route::resource('student-scores', StudentScoreController::class)->only(['index', 'destroy']);
});
