<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\EntryController;

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

Route::get('/register', [RegisteredUserController::class, 'create'])->name('register');
Route::post('/register', [RegisteredUserController::class, 'store'])->name('register.submit');

Route::get('/login', [AuthenticatedSessionController::class, 'create'])->name('login');
Route::post('/login', [AuthenticatedSessionController::class, 'store'])->name('login.submit');
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');

Route::middleware(['auth'])->group(function () {
    Route::get('/lietotaja_interfeiss', function () {
        return view('lietotaja_interfeiss');
    })->name('lietotaja_interfeiss');

    Route::get('/lietotaja_interfeiss_buttons', [UserController::class, 'showUserInterface'])->name('lietotaja_interfeiss_buttons');
    Route::get('/entry_creation_page', [UserController::class, 'showEntryCreationPage'])->name('entry_creation_page');
    Route::get('/search_entries', [UserController::class, 'searchByDate'])->name('search_entries');

    Route::post('/save-diary-entry', [EntryController::class, 'saveDiaryEntry'])->name('save_diary_entry');
});
