<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\ChatController;

Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Route::post('/login', [AuthController::class, 'login']);

Route::middleware([\App\Http\Middleware\CheckLogin::class])->group(function () {
    Route::get('/', [ChatController::class, 'index'])->name('chat');
    Route::post('/chat/fetch', [ChatController::class, 'fetchMessages'])->name('chat.fetch');
    Route::post('/chat/send', [ChatController::class, 'sendMessage'])->name('chat.send');
    Route::post('/chat/edit', [ChatController::class, 'editMessage'])->name('chat.edit');
    Route::post('/chat/delete', [ChatController::class, 'deleteMessage'])->name('chat.delete');
    Route::post('/chat/upload', [ChatController::class, 'uploadFile'])->name('chat.upload');
    
    Route::post('/profile/update', [ChatController::class, 'updateProfile'])->name('profile.update');
    
    Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
    
    Route::get('/surprise', [ChatController::class, 'surprise'])->name('surprise');
});
