<?php

use App\Http\Controllers\Api\Admin\RankingController as AdminRankingController;
use App\Http\Controllers\api\admin\ToprankController as AdminToprankController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Web\Admin\UserController;
use App\Http\Controllers\Web\Admin\AttendanceController;
use App\Http\Controllers\Web\Admin\PermissionController;
use App\Http\Controllers\Web\Admin\LocationController;
use App\Http\Controllers\Web\Admin\ReportController;
use App\Http\Controllers\Web\Admin\RankingController;

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return redirect()->route('auth.login');
});

Route::get('/login', fn()=>view('auth.login'))->name('auth.login');

Route::middleware(['web.auth:admin'])->group(function () {
    Route::get('/dashboard', fn()=>view('dashboard.index'))->name('dashboard.index');
    Route::get('/profile', fn()=>view('dashboard.profile'))->name('profile.index');

    Route::prefix('users')->name('users.')->group(function () {
        Route::get('/', fn()=>view('dashboard.user'))->name('index');
    });

    Route::prefix('attendances')->name('attendances.')->group(function () {
        Route::get('/', fn()=>view('dashboard.attendance'))->name('index');
    });

    Route::prefix('permissions')->name('permissions.')->group(function () {
        Route::get('/', fn()=>view('dashboard.permission'))->name('index');
    });

    Route::prefix('locations')->name('locations.')->group(function () {
        Route::get('/', fn()=>view('dashboard.location'))->name('index');
    });

    Route::prefix('reports')->name('reports.')->group(function () {
        Route::get('/', fn()=>view('dashboard.report'))->name('index');
    });

    Route::prefix('ranking')->name('ranking.')->group(function () {
        Route::get('/', fn()=>view('dashboard.ranking'))->name('index');
    });

    Route::prefix('toprank')->name('toprank.')->group(function () {
        // ini untuk izin
        Route::get('/', [AdminToprankController::class, 'index'])->name('index');
        Route::get('/izin', [AdminToprankController::class, 'index'])->name('izin');
        Route::get('/user/{id}/permissions', [AdminToprankController::class, 'userPermissionsWeb'])->name('toprank.user_permissions');
        // ini untuk absen
        Route::get('/absensi', [AdminToprankController::class, 'absensi'])->name('absensi');
        Route::get('/absensi/user/{userId}/attendances', [AdminToprankController::class, 'userAttendances'])->name('absensi.attendances');
    });
});