<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Web\LineController;
use App\Http\Controllers\Web\ExportController;
use App\Http\Controllers\Web\GroupController;
use App\Http\Controllers\Web\HomeController;
use App\Http\Controllers\Web\ImportController;
use App\Http\Controllers\Web\RequestController;
use App\Http\Controllers\Web\SettingController;
use App\Http\Controllers\Web\CategoryController;
use App\Models\Export;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Route::get('/', [HomeController::class, 'index'])->name('home');
Route::group(['middleware' => 'check_october_session'], function () {
    Route::get('imports', [ImportController::class, 'index'])->name('imports');
    Route::get('/', [ExportController::class, 'index'])->name('exports');
    Route::get('download/{group}', [GroupController::class, 'download'])->name('download');
    Route::post('requests', [RequestController::class, 'store'])->name('requests.store');
    Route::get('lang/{lang}', [HomeController::class, 'lang'])->name('lang');
});


Route::group(['middleware' => 'auth:sanctum'], function () {
    Route::post('imports/import', [ImportController::class, 'import'])->name('imports.import');
    Route::post('exports/import', [ExportController::class, 'import'])->name('exports.import');
    Route::get('import-status', [ExportController::class, 'status'])->name('import-status');

    Route::get('lines', [LineController::class, 'index'])->name('lines');
    Route::post('lines', [LineController::class, 'store'])->name('lines.store');
    Route::delete('lines/{export}', [LineController::class, 'destroy'])->name('lines.destroy');

    Route::get('requests', [RequestController::class, 'index'])->name('requests');
    Route::delete('requests/{request}', [RequestController::class, 'destroy'])->name('requests.destroy');

    Route::get('settings', [SettingController::class, 'index'])->name('settings');
    Route::post('settings', [SettingController::class, 'store'])->name('settings.store');

    Route::get('categories', [CategoryController::class, 'index'])->name('categories');
    Route::post('categories', [CategoryController::class, 'store'])->name('categories.store');
    Route::delete('categories/{category}', [CategoryController::class, 'destroy'])->name('categories.destroy');

    Route::get('groups', [GroupController::class, 'index'])->name('groups');
    Route::post('groups', [GroupController::class, 'store'])->name('groups.store');
    Route::put('groups/{group}', [GroupController::class, 'update'])->name('groups.update');
    Route::delete('groups/{group}', [GroupController::class, 'destroy'])->name('groups.destroy');

    Route::get('upgrade', [HomeController::class, 'upgrade']);

    Route::get('logout-confirm', [HomeController::class, 'logoutConfirm'])->name('logout_confirm');
});
