<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SigController;
use App\Http\Controllers\AboutController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\AduanController;
use App\Http\Controllers\KontakController;

// ADMIN
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\TpsController;
use App\Http\Controllers\Admin\KategoriTpsController;
use App\Http\Controllers\Admin\SampahController;
use App\Http\Controllers\Admin\AduanController as AdminAduanController;
use App\Http\Controllers\Admin\ProfilController;

/*
|--------------------------------------------------------------------------
| ROUTE PUBLIK / USER
|--------------------------------------------------------------------------
*/

Route::get('/', function () {
    return view('user.index');
});

Route::get('/', [IndexController::class, 'index'])->name('user.index');
Route::get('/about', [AboutController::class, 'index'])->name('user.about');
Route::get('/about/{id}', [AboutController::class, 'show'])->name('user.about.kategori');

Route::get('/sig-tps', [SigController::class, 'index'])->name('user.sig-tps');
Route::get('/tps/{id}', [SigController::class, 'show'])->name('user.detail-tps');

Route::get('/aduan-tps', [AduanController::class, 'index'])->name('user.aduan');
Route::post('/aduan-tps', [AduanController::class, 'store'])->name('user.aduan.store');

Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');

require __DIR__.'/auth.php';

/*
|--------------------------------------------------------------------------
| ROUTE ADMIN (PROTECTED)
|--------------------------------------------------------------------------
*/

Route::middleware(['auth'])
    ->prefix('admin')
    ->name('admin.')
    ->group(function () {

    Route::get('/dashboard', [DashboardController::class, 'index'])
        ->name('dashboard');

    // TPS
    Route::resource('tps', TpsController::class)->except(['show']);

    // KATEGORI TPS
    Route::resource('kategori', KategoriTpsController::class)->except(['show']);

    // SAMPAH
    Route::resource('sampah', SampahController::class)->except(['show']);

    // ADUAN
    Route::get('/aduan', [AdminAduanController::class, 'index'])->name('aduan.index');
    Route::get('/aduan/{id}', [AdminAduanController::class, 'show'])->name('aduan.show');
    Route::post('/aduan/{id}/tanggapi', [AdminAduanController::class, 'tanggapi'])->name('aduan.tanggapi');
    Route::delete('/aduan/{id}', [AdminAduanController::class, 'destroy'])->name('aduan.destroy');

    // PROFIL
    Route::get('/profil', [ProfilController::class, 'index'])->name('profil');
    Route::post('/profil', [ProfilController::class, 'update'])->name('profil.update');
});
