<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ApplicationController;
use App\Http\Controllers\Admin\ApplicationAdminController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});
Route::post('/solicitudes', [ApplicationController::class, 'store'])->middleware('throttle:10,1')->name('applications.store');
Route::post('/solicitudes/autorizacion-radomiro/vista-previa', [ApplicationController::class, 'previewRadomiroAuthorization'])->middleware('throttle:30,1')->name('applications.radomiro-authorization.preview');
Route::get('/solicitudes/{application}/autorizacion-radomiro', [ApplicationController::class, 'radomiroAuthorization'])->middleware(['signed', 'throttle:30,1'])->name('applications.radomiro-authorization');
Route::post('/solicitudes/autorizacion-gabriela/vista-previa', [ApplicationController::class, 'previewGabrielaAuthorization'])->middleware('throttle:30,1')->name('applications.gabriela-authorization.preview');
Route::get('/solicitudes/{application}/autorizacion-gabriela', [ApplicationController::class, 'gabrielaAuthorization'])->middleware(['signed', 'throttle:30,1'])->name('applications.gabriela-authorization');

Route::get('/dashboard', [ApplicationAdminController::class, 'dashboard'])->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::post('/session/keep-alive', fn () => response()->noContent())->name('session.keep-alive');
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
    Route::get('/admin/inscripciones', [ApplicationAdminController::class, 'index'])->name('admin.applications.index');
    Route::get('/admin/inscripciones/{application}', [ApplicationAdminController::class, 'show'])->name('admin.applications.show');
    Route::get('/admin/inscripciones/{application}/editar', [ApplicationAdminController::class, 'edit'])->name('admin.applications.edit');
    Route::patch('/admin/inscripciones/{application}/datos', [ApplicationAdminController::class, 'updateData'])->name('admin.applications.update-data');
    Route::get('/admin/inscripciones/{application}/pdf', [ApplicationAdminController::class, 'pdf'])->name('admin.applications.pdf');
    Route::get('/admin/inscripciones/{application}/autorizacion-radomiro', [ApplicationAdminController::class, 'radomiroAuthorization'])->name('admin.applications.radomiro-authorization');
    Route::get('/admin/inscripciones/{application}/autorizacion-gabriela', [ApplicationAdminController::class, 'gabrielaAuthorization'])->name('admin.applications.gabriela-authorization');
    Route::get('/admin/inscripciones/{application}/adjuntos/{index}', [ApplicationAdminController::class, 'attachment'])->whereNumber('index')->name('admin.applications.attachment');
    Route::patch('/admin/inscripciones/{application}', [ApplicationAdminController::class, 'update'])->name('admin.applications.update');
});

require __DIR__.'/auth.php';
