<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Auth\EveLoginController;
use App\Http\Controllers\Dashboard\DashboardController;
use App\Http\Controllers\Auth\EveLogoutController;
use App\Http\Controllers\Finance\BuybackController;

/**
 * Login Display Pages
 */

Route::get('/', function() {
    if(Auth::check()) {
        return redirect('/dashboard');
    } else {
        return view('auth.eve');
    }
});

Route::get('/buyback', [BuybackController::class, 'display'])->name('buyback');
Route::post('/buyback/process', [BuybackController::class, 'process'])->name('buyback.process');

Route::get('/login/eve', [EveLoginController::class, 'redirectToProvider'])->name('login.eve');
Route::get('/login/eve/callback', [EveLoginController::class, 'handleProviderCallback'])->name('login.eve.callback');
Route::post('/logout', [EveLoginController::class, 'logout'])->name('logout');

Route::group(['middleware' => ['auth']], function() {
    /**
     * Dashboard pages
     */
    Route::get('/dashboard', [DashboardController::class, 'display'])->name('dashboard');
});

/**
 * Routes which require auth and Guest Role
 */
Route::group(['middleware' => ['auth', 'role:Guest']], function() {

});

/**
 * Routes which require auth and User Role
 */
Route::group(['middleware' => ['auth', 'role:User']], function() {

});

/**
 * Routes which require auth and Admin Role
 */
Route::group(['middleware' => ['auth', 'role:Admin']], function() {

});
