<?php

use Illuminate\Support\Facades\Route;
use App\Http\Middleware\Session;
use App\Http\Middleware\Profile;
use App\Http\Controllers\Auth\CustomLoginController;
use App\Http\Controllers\Auth\CustomRegisterController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\AjaxController;
use App\Http\Controllers\FrontController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('forgotpass',[CustomLoginController::class,'forgotpass'])->name('forgotpass');
Route::post('forgotpass',[CustomLoginController::class,'forgotpass_post'])->name('forgotpass_post');

Route::get('login',[CustomLoginController::class,'index'])->name('login');
Route::post('login',[CustomLoginController::class,'post_login'])->name('post_login');

Route::get('register',[CustomRegisterController::class,'index'])->name('register');
Route::post('register',[CustomRegisterController::class,'post_register'])->name('post_register');
Route::post('get/kabupaten',[AjaxController::class,'getKabupaten'])->name('getKabupaten');
Route::post('get/kecamatan',[AjaxController::class,'getKecamatan'])->name('getKecamatan');
Route::post('get/sekolah',[AjaxController::class,'getSekolah'])->name('getSekolah');
Route::post('sekolahNpsn',[AjaxController::class,'sekolahNpsn'])->name('sekolahNpsn');
Route::post('uploadTemp', [AjaxController::class, 'uploadTemp'])->name('uploadTemp');
Route::post('uploadTempImage', [AjaxController::class, 'uploadTempImage'])->name('uploadTempImage');
Route::post('checkEmail', [AjaxController::class, 'checkEmail'])->name('checkEmail');
Route::post('sendCode', [AjaxController::class, 'sendCode'])->name('sendCode');
Route::get('hash/{hash}', function ($hash) {
    return Hash::make($hash);
});
Route::middleware([Session::class,Profile::class])->name('modules.')->group(function () {
    include_route_files(__DIR__ . '/modules');
    Route::get('logout',[CustomLoginController::class,'logout'])->name('logout');
});

Route::middleware([Session::class])->name('modules.')->group(function () {
    Route::get('profile-sekolah/lengkapi/{npsn}',[ProfileController::class,'lengkapi'])->name('profile.lengkapi');
    Route::post('profile-sekolah/lengkapi',[ProfileController::class,'updateLengkapi'])->name('profile.updateLengkapi');
});

Route::get('/',[FrontController::class,'index'])->name('index');
// Route::get('/new',[FrontController::class,'indexNew'])->name('indexNew');
Route::get('/sekolah',[FrontController::class,'sekolah'])->name('sekolah');
Route::get('/kegiatan',[FrontController::class,'kegiatan'])->name('kegiatan');
Route::get('/kegiatan/{slug}',[FrontController::class,'kegiatan_detail'])->name('kegiatan_detail');
// Route::get('/galeri',[FrontController::class,'galeri'])->name('galeri');
Route::get('/data/sekolah',[FrontController::class,'dataSekolah'])->name('dataSekolah');

// Auth::routes();
// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
