<?php

use App\Http\Controllers\PushSubscriptionController;
use App\Http\Controllers\PwaManifestController;
use App\Livewire\CollabsBoard;
use App\Livewire\WorkspaceSettings;
use Illuminate\Support\Facades\Route;

Route::get('/site.webmanifest', PwaManifestController::class)->name('pwa.manifest');

Route::view('/', 'landing');

Route::redirect('dashboard', 'app')
    ->middleware(['auth', 'verified'])
    ->name('dashboard');

Route::get('app', CollabsBoard::class)
    ->middleware(['auth', 'verified', 'collabs.workspace'])
    ->name('collabs.board');

Route::get('settings/workspace', WorkspaceSettings::class)
    ->middleware(['auth', 'verified', 'collabs.workspace'])
    ->name('collabs.settings');

Route::view('profile', 'profile')
    ->middleware(['auth'])
    ->name('profile');

Route::middleware(['auth', 'verified'])->prefix('push')->group(function (): void {
    Route::get('/vapid-public-key', [PushSubscriptionController::class, 'vapidPublicKey'])->name('push.vapid-public-key');
    Route::post('/subscribe', [PushSubscriptionController::class, 'subscribe'])->name('push.subscribe');
    Route::post('/unsubscribe', [PushSubscriptionController::class, 'unsubscribe'])->name('push.unsubscribe');
    Route::post('/test', [PushSubscriptionController::class, 'test'])->name('push.test');
});

require __DIR__.'/auth.php';
