<?php

/******************************************************************
 *  
 *  S.P. Framework v1.3.0
 *  --------------------------------------------------------------
 *  
 *  Welcome to the SelfPhp Framework, version 1.3.0!
 *  
 *  This framework is designed to streamline the development process
 *  by providing a robust routing system. Use the 'Route' class to
 *  define and manage your application's routes effortlessly.
 *  
 *  Explore the power of S.P. Framework to create scalable and
 *  maintainable web applications with ease.
 *  
 *  For documentation and examples, visit:
 *  https://github.com/Gicehajunior/selfphp-framework.git
 * 
 *  @author Giceha Junior
 *  @version 1.3.0
 *  @license MIT License
 *  
 ******************************************************************/

use SelfPhp\Route;

use App\Http\Auth\AuthController;
use App\Http\Controllers\Web\DashboardController;
use App\Http\Controllers\Web\DictionaryController;
use App\Http\Controllers\Web\ImportController;
use App\Http\Controllers\Web\HomeController;

use App\Http\Middlewares\AuthMiddleware;

/*
|--------------------------------------------------------------------------
| Public Routes
|--------------------------------------------------------------------------
*/

Route::get('/', [AuthController::class, 'login']);
Route::get('/login', [AuthController::class, 'login']);
Route::get('/register', [AuthController::class, 'signup']);

Route::post('/admin/login', [AuthController::class, 'login_user']); 
Route::post('/admin/register', [AuthController::class, 'signup_user']);

Route::get('/logout', [AuthController::class, 'logout']);

/*
|--------------------------------------------------------------------------
| Protected Routes (Auth Middleware)
|--------------------------------------------------------------------------
*/

Route::get('/dashboard', [DashboardController::class, 'index'], [AuthMiddleware::class]);

/*
|--------------------------------------------------------------------------
| Dictionary Routes (Protected)
|--------------------------------------------------------------------------
*/

// Categories
Route::get('/dictionary/categories', [DictionaryController::class, 'categories'], [AuthMiddleware::class]);

Route::get('/dictionary/category/create', [DictionaryController::class, 'createCategory'], [AuthMiddleware::class]);
Route::post('/dictionary/category/create', [DictionaryController::class, 'createCategory'], [AuthMiddleware::class]);

Route::get('/dictionary/category/update', [DictionaryController::class, 'updateCategory'], [AuthMiddleware::class]);
Route::post('/dictionary/category/update', [DictionaryController::class, 'updateCategory'], [AuthMiddleware::class]);

Route::post('/dictionary/category/delete', [DictionaryController::class, 'deleteCategory'], [AuthMiddleware::class]);

// Words
Route::get('/dictionary/words', [DictionaryController::class, 'index'], [AuthMiddleware::class]);

Route::get('/dictionary/word/create', [DictionaryController::class, 'createWord'], [AuthMiddleware::class]);
Route::post('/dictionary/word/create', [DictionaryController::class, 'createWord'], [AuthMiddleware::class]);

Route::get('/dictionary/bulk-import', [ImportController::class, 'importWords'], [AuthMiddleware::class]);
Route::post('/dictionary/bulk-import', [ImportController::class, 'importWords'], [AuthMiddleware::class]);

Route::get('/dictionary/word/update', [DictionaryController::class, 'updateWord'], [AuthMiddleware::class]);
Route::post('/dictionary/word/update', [DictionaryController::class, 'updateWord'], [AuthMiddleware::class]);

Route::get('/dictionary/word/show', [DictionaryController::class, 'showWord'], [AuthMiddleware::class]);

Route::get('/dictionary/word/delete', [DictionaryController::class, 'deleteWord'], [AuthMiddleware::class]);

/*
|--------------------------------------------------------------------------
| Fallback
|--------------------------------------------------------------------------
*/

Route::get('/404', [AuthController::class, 'notFoundErrorPage']);