<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\SpeciesSurveyController;
use App\Http\Controllers\Admin\DashboardController;
use Illuminate\Support\Facades\Route;

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

Route::get('/dashboard', function () {
    return redirect()->route('admin.dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware(['auth', 'verified'])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/users', [UserController::class, 'index'])->name('users.index');
    Route::get('/species-surveys', [SpeciesSurveyController::class, 'index'])->name('species-surveys.index');
    Route::get('/species-surveys/{species_survey}/edit', [SpeciesSurveyController::class, 'edit'])->name('species-surveys.edit');
    Route::put('/species-surveys/{species_survey}', [SpeciesSurveyController::class, 'update'])->name('species-surveys.update');
    Route::delete('/species-surveys/{species_survey}', [SpeciesSurveyController::class, 'destroy'])->name('species-surveys.destroy');
});

Route::middleware('auth')->group(function () {
    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');
});

require __DIR__.'/auth.php';
