<?php

use Illuminate\Support\Facades\Route;
use App\Livewire\Counter;

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

Route::get('/counter', Counter::class);

// Parks routes
Route::get('/parks', \App\Livewire\ParkListComponent::class)->name('parks.index');
Route::get('/parks/create', function () {
    return 'Create Park';
})->name('parks.create');
Route::get('/parks/{slug}', function (string $slug) {
    [$park, $isHistorical] = \App\Models\Park::getBySlug($slug);
    
    if (!$park) {
        abort(404);
    }
    
    // If using a historical slug, redirect to the current slug
    if ($isHistorical) {
        return redirect()->route('parks.show', ['slug' => $park->slug]);
    }
    
    return view('parks.show', ['park' => $park]);
})->name('parks.show');
Route::get('/parks/{park}/edit', function () {
    return 'Edit Park';
})->name('parks.edit');

// Photo routes
Route::prefix('parks/{park}/photos')->name('parks.photos.')->group(function () {
    Route::get('/', [\App\Http\Controllers\PhotoController::class, 'index'])->name('index');
    Route::post('/', [\App\Http\Controllers\PhotoController::class, 'store'])->name('store');
    Route::put('/reorder', [\App\Http\Controllers\PhotoController::class, 'reorder'])->name('reorder');
    Route::get('/{photo}', [\App\Http\Controllers\PhotoController::class, 'show'])->name('show');
    Route::put('/{photo}', [\App\Http\Controllers\PhotoController::class, 'update'])->name('update');
    Route::delete('/{photo}', [\App\Http\Controllers\PhotoController::class, 'destroy'])->name('destroy');
    Route::put('/{photo}/featured', [\App\Http\Controllers\PhotoController::class, 'setFeatured'])->name('featured');
});

// Rides routes
Route::get('/rides', function () {
    return 'Rides Index';
})->name('rides.index');

// Auth routes
Route::get('/login', function () {
    return 'Login';
})->name('login');

Route::get('/register', function () {
    return 'Register';
})->name('register');

Route::post('/logout', function () {
    return 'Logout';
})->name('logout');

// Settings routes
Route::get('/settings', function () {
    return 'Settings';
})->name('settings');

// Legal routes
Route::get('/terms', function () {
    return 'Terms';
})->name('terms');

Route::get('/privacy', function () {
    return 'Privacy';
})->name('privacy');

// Profile routes
Route::get('/profile/{username}', function () {
    return 'Profile';
})->name('profile.show');

// Search route
Route::get('/search', \App\Livewire\SearchComponent::class)->name('search');
