<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\NoteController;
use App\Http\Controllers\GoogleFactorController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\TransferController;

use App\Http\Controllers\DomainTransferController;
use App\Http\Controllers\Hub\HubRedirectionController;
use App\Http\Controllers\UserAuth\TwoFAVerificationController;

Route::post('/logout' , [LoginController::class , 'logout'])->name('logout');
Route::get('/logout' , [LoginController::class , 'logout'])->name('logout');


Route::group(['middleware' => 'auth'] , function(){

    Route::controller(TwoFAVerificationController::class)->group(function(){
        Route::get('/servlet', 'servlet')->name('auth.servlet');
        Route::get('/GoogleF2' , 'GoogleF2')->name('auth.google2fa');
        Route::post('/resend-servlet-verification', 'resendServletVerificationCode')->name('auth.resend.servlet');
        Route::post('/verify-servlet', 'verifyServlet')->name('auth.verify.servlet');
        Route::post('/google-fa-check', 'verifyGoogle2FA')->name('auth.verify.google2fa');
    });


    Route::group(['middleware' => ['OTPValidation']] , function(){

        Route::get('/', [DashboardController::class , 'index'])->name('home');

        Route::controller(HubRedirectionController::class)->group(function(){
            Route::get('/GoToHub', 'GoToHub')->name('redirect.to.hub');
            Route::get('/GoToHubCart', 'GoToHubCart')->name('redirect.to.hub.cart');
        });

        Route::controller(UserController::class)->group(function(){
            Route::get('/UserProfile', 'UserProfile')->name('UserProfile');
            Route::post('/UserProfileUpdate', 'UserProfileUpdate')->name('UserProfileUpdate');
            Route::get('/ChangePassword', 'ChangePassword')->name('ChangePassword');
            Route::post('/ChangePasswordSave', 'ChangePasswordSave')->name('ChangePasswordSave');
        });

        Route::resource('/Note'  , NoteController::class);

        Route::controller(GoogleFactorController::class)->group(function(){
            Route::get('/profile-google2fa-update', 'Google2FAUpdatePage')->name('profile.google2fa.page');
            Route::post('/complete-update', 'verifyGoogle2Fa')->name('profile.google2fa.verify');
        });

    
        Route::controller(DomainTransferController::class)->group(function(){
            Route::get('/domain-transfer', 'index')->name('domain.transfer.index'); 
            Route::post('/domain-check', 'domain_check')->name('domain.transfer.check'); 
            Route::post('/domain-transfer-to', 'domain_transfer_to')->name('domain.transfer.to');
            Route::post('/domain-transfer-save', 'save_transfer')->name('domain.transfer.save');
            Route::post('/domain-leap-transfer-save', 'save_leap_transfer')->name('domain.leap.transfer.save');
        });
        
        Route::get('/LeapTransferResponse/{option}/{uni_id}/token={token}' , [TransferController::class , 'LeapTransferResponse']);

    });

});