<?php

use App\Http\Controllers\SigController;
use App\Http\Controllers\AboutController;
use App\Http\Controllers\Admin\AduanController as AdminAduanController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\KategoriTpsController;
use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\Admin\ProfilController;
use App\Http\Controllers\Admin\SampahController;
use App\Http\Controllers\Admin\TpsController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\AduanController;
use App\Http\Controllers\KontakController;
use Illuminate\Support\Facades\Route;

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

Route::get('/', function () {
    return view('welcome');
});

Route::get('/index', [IndexController::class, 'index'])->name('user.index');
Route::get('/about', [AboutController::class, 'index'])->name('user.about');
Route::get('/about-tps', [AboutController::class, 'tps'])->name('user.about-tps');

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-tps');
Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');

/*
|--------------------------------------------------------------------------
| ROUTE AUTH ADMIN
|--------------------------------------------------------------------------
*/

Route::get('/admin/login', [LoginController::class, 'index'])->name('admin.login');
Route::post('/admin/login', [LoginController::class, 'process'])->name('admin.login.process');
Route::post('/admin/logout', [LoginController::class, 'logout'])->name('admin.logout');

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

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

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

    // TPS ADMIN
    Route::get('/tps', [TpsController::class, 'index'])->name('tps.index');
    Route::get('/tps/create', [TpsController::class, 'create'])->name('tps.create');
    Route::post('/tps', [TpsController::class, 'store'])->name('tps.store');
    Route::get('/tps/{id}/edit', [TpsController::class, 'edit'])->name('tps.edit');
    Route::put('/tps/{id}', [TpsController::class, 'update'])->name('tps.update');
    Route::delete('/tps/{id}', [TpsController::class, 'destroy'])->name('tps.destroy');

    // KATEGORI TPS ADMIN
    Route::get('/kategori', [KategoriTpsController::class, 'index'])->name('kategori.index');
    Route::get('/kategori/create', [KategoriTpsController::class, 'create'])->name('kategori.create');
    Route::post('/kategori', [KategoriTpsController::class, 'store'])->name('kategori.store');
    Route::get('/kategori/{id}/edit', [KategoriTpsController::class, 'edit'])->name('kategori.edit');
    Route::put('/kategori/{id}', [KategoriTpsController::class, 'update'])->name('kategori.update');
    Route::delete('/kategori/{id}', [KategoriTpsController::class, 'destroy'])->name('kategori.destroy');

    // SAMPAH ADMIN
    Route::get('/sampah', [SampahController::class, 'index'])->name('sampah.index');
    Route::get('/sampah/create', [SampahController::class, 'create'])->name('sampah.create');
    Route::post('/sampah', [SampahController::class, 'store'])->name('sampah.store');
    Route::get('/sampah/{id}/edit', [SampahController::class, 'edit'])->name('sampah.edit');
    Route::put('/sampah/{id}', [SampahController::class, 'update'])->name('sampah.update');
    Route::delete('/sampah/{id}', [SampahController::class, 'destroy'])->name('sampah.destroy');

    // ADUAN ADMIN
    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::post('/aduan/{id}', [AdminAduanController::class, 'destroy'])->name('aduan.destroy');

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