<?php

use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

use App\Helpers\PageBlocksHelper;

use App\Http\Controllers\Backend\PageBuilder;
use App\Http\Controllers\PageRender;

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'menuLinks' => PageBlocksHelper::mainMenuLinks()
    ]);
})->name('forsiden');

Route::get('/privacypolicy', function () {
    return Inertia::render('Welcome');
})->name('privacyPolicy');

Route::get('/useterms', function () {
    return Inertia::render('Welcome');
})->name('useTerms');

Route::get('/salesterms', function () {
    return Inertia::render('Welcome');
})->name('salesTerms');

Route::get('/p/{slug}', [PageRender::class, 'view'])->name('page.view');

Route::middleware(['auth', 'verified'])->group(function() {
    Route::get('/dashboard/page-admin', [PageBuilder::class, 'index'])->name('page-builder.index');
    Route::get('/dashboard/page-admin/landing-pages/create', [PageBuilder::class, 'createLandingPage'])->name('page-builder.landing-page.create');
    Route::get('/dashboard/page-admin/builder/{pageVersion}', [PageBuilder::class, 'editLandingPage'])->name('page-builder.builder.edit');
    Route::get('/dashboard/page-admin/preview/{pageVersion}', [PageBuilder::class, 'preview'])->name('page-builder.landing-page.preview');

    Route::post('/dashboard/page-admin/landing-pages/create', [PageBuilder::class, 'storeLandingPage'])->name('page-builder.landing-page.store');
    Route::post('/dasboard/page-admin/landing-pages/save-as', [PageBuilder::class, 'saveAsLandingPage'])->name('page-builder.landing-page.save-as');
    Route::delete('/dashboard/page-admin/landing-pages/delete', [PageBuilder::class, 'deleteLandingPage'])->name('page-builder.landing-page.delete');
    Route::patch('/dashboard/page-admin/landing-pages/patch', [PageBuilder::class, 'patchLandingPage'])->name('page-builder.landing-page.patch');
    Route::put('/dashboard/page-admin/landing-pages/set-active', [PageBuilder::class, 'setLandingPageRevisionActive'])->name('page-builder.landing-page.set-active');
});



require __DIR__.'/settings.php';
require __DIR__.'/auth.php';
