<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\CustomerController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\ManagementController;
use App\Http\Controllers\ManagementSingleController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\UserManagement\Administrator\AdministratorController;

use App\Http\Controllers\UserManagement\Users\UserController;
use App\Http\Middleware\SessionCheck;
use Illuminate\Support\Facades\Route;



Route::middleware(SessionCheck::class)->get('/', [DashboardController::class, 'index'])->name('dashboard.view');
Route::get('/login', [AuthController::class, 'loginPage'])->name('login.view');
Route::post('/login-p', [AuthController::class, 'login'])->name('login.post');

Route::prefix('user-management')->group(function () {
    Route::prefix('administrator')->group(function () {
        Route::get('/', [AdministratorController::class, 'index'])->name('administrator.view');
    });
    Route::prefix('user')->group(function () {
        Route::get('/', [UserController::class, 'index'])->name('user.view');
        Route::get('/add', [UserController::class, 'create'])->name('user.add');
        Route::post('/store', [UserController::class, 'store'])->name('user.store');
        Route::get('/edit/{id}', [UserController::class, 'edit'])->name('user.edit');
        Route::post('/update/{id}', [UserController::class, 'update'])->name('user.update');

    });

});
Route::prefix('customer')->group(function () {
    Route::get('/', [CustomerController::class, 'index'])->name('customer.view');
    Route::get('/add', [CustomerController::class, 'create'])->name('customer.add');
    Route::get('/detail/{id}', [CustomerController::class, 'show'])->name('customer.detail');
    Route::get('/edit/{id}', [CustomerController::class, 'edit'])->name('customer.edit');
    Route::post('/store', [CustomerController::class, 'store'])->name('customer.store');
    Route::post('/update/{id}', [CustomerController::class, 'update'])->name('customer.update');
});



Route::prefix('auth')->group(function () {
    Route::get('/change-password',[AuthController::class, 'changePassword'])->name('auth.change.password');
    Route::post('/change-password-p',[AuthController::class, 'changePasswordP'])->name('auth.change.password.post');
    Route::post('/logout', [AuthController::class, 'logout'])->name('auth.logout');
});

Route::prefix('report')->group(function () {
    Route::get('/', [ReportController::class, 'index'])->name('report.view');
});

Route::prefix('management')->group(function () {
    Route::get('/plan-visit', [ManagementController::class, 'index'])->name('management.view');
    Route::get('/modul-saya', [ManagementSingleController::class, 'index'])->name('management-single.view');
    Route::post('/modul-saya', [ManagementSingleController::class, 'store'])->name('management-single.store');
    Route::get('/modul-saya/detail/{id}', [ManagementSingleController::class, 'detail'])->name('management-single.detail'); // Added this line
    Route::get('/detail/{id}', [ManagementController::class, 'detail'])->name('management.detail');
    Route::post('/approve/{id}', [ManagementController::class, 'approve'])->name('management.approve');
    Route::post('/reject/{id}', [ManagementController::class, 'reject'])->name('management.reject');
});
