<?php

use App\Http\Controllers\ContactController;
use App\Http\Controllers\DokumenDesaController;
use App\Http\Controllers\NewsController;
use App\Http\Controllers\PengaduanController;
use App\Http\Controllers\PengajuanSuratController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\PotensiDesaController;
use Illuminate\Support\Facades\Route;

// Halaman Utama / Beranda
Route::get('/', [HomeController::class, 'index'])->name('home');

// Profil Desa
Route::get('/profildesa', [PotensiDesaController::class, 'index'])->name('profildesa');

// Halaman Layanan
Route::get('/layanan', [DokumenDesaController::class, 'index'])->name('pages.layanan.layanan');

// Portal Berita
Route::get('/berita', [NewsController::class, 'index'])->name('Berita');
Route::get('/berita/{slug}', [NewsController::class, 'show'])->name('news.show');

// Layanan Pengaduan Masyarakat (keluhan)
Route::get('/pengaduan', [PengaduanController::class, 'create'])->name('pengaduan.create');
Route::post('/pengaduan', [PengaduanController::class, 'store'])->middleware('throttle:3,1')->name('pengaduan.store');
Route::get('/check-status', [PengaduanController::class, 'checkStatus'])->middleware('throttle:15,1')->name('pengaduan.check-status');
Route::get('/pengaduan/download/{idOrTicket}', [PengaduanController::class, 'downloadSecureLampiran'])->middleware('throttle:15,1')->name('pengaduan.download');

// Layanan Pengajuan Surat
Route::get('/pengajuan-surat', [PengajuanSuratController::class, 'create'])->name('pengajuan-surat.create');
Route::post('/pengajuan-surat', [PengajuanSuratController::class, 'store'])->middleware('throttle:3,1')->name('pengajuan-surat.store');

// Kontak Kami (Form Submit)
Route::post('/contact', [ContactController::class, 'store'])->middleware('throttle:5,1')->name('contact.store');

// Password Reset dengan OTP
use App\Http\Controllers\PasswordResetController;

Route::prefix('admin')->group(function () {
    Route::get('/lupa-password', [PasswordResetController::class, 'showRequestForm'])->name('password.request');
    Route::post('/lupa-password', [PasswordResetController::class, 'sendOtp'])->name('password.send-otp');
    Route::get('/reset-password', [PasswordResetController::class, 'showResetForm'])->name('password.reset.form');
    Route::post('/reset-password', [PasswordResetController::class, 'resetPassword'])->name('password.reset');
});
