<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\WalletController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SantriController;
use App\Http\Controllers\PaymentTypeController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\HomeController;
use Inertia\Inertia;

Route::get('/', function () {
    return redirect()->route('login');
});

Route::get('/login', function () {
    return redirect()->route('login');
});

Route::middleware('auth')->group(function () {

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

    // profile
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::post('/update-profile/{id}', [ProfileController::class, 'updateProfile'])->name('profile.update');

    // santri
    Route::get('/data-santri', [SantriController::class, 'index'])->name('indexSantri');
    Route::post('/addusers', [SantriController::class, 'store'])->name('storeSantri');
    Route::post('/updateusers/{id}', [SantriController::class, 'update'])->name('updateSantri');
    Route::post('/deleteusers/{id}', [SantriController::class, 'destroy'])->name('deleteSantri');

    // payment type
    Route::get('/data-payment-type', [PaymentTypeController::class, 'index'])->name('indexPaymentType');
    Route::post('/addpayment_types', [PaymentTypeController::class, 'store'])->name('storePaymentType');
    Route::post('/updatepayment_types/{id}', [PaymentTypeController::class, 'update'])->name('updatePaymentType');
    Route::post('/deletepayment_types/{id}', [PaymentTypeController::class, 'destroy'])->name('deletePaymentType');

    // manual payment
    Route::get('/index-manual-payment', [PaymentController::class, 'indexManualPayment'])->name('indexManualPayment');
    Route::post('/updatepayments/{paymentId}', [PaymentController::class, 'manualPayment'])->name('manualPayment');

    // wallet
    Route::get('/wallet-user', [WalletController::class, 'walletUser'])->name('walletUser');

    Route::get('profile-settings', function () {
        return Inertia::render('ProfileSettings');
    });
});

require __DIR__ . '/auth.php';
