<?php

use App\Modules\BaseAuth\Controllers\LoginController;
use App\Modules\BaseAuth\Controllers\RegisterController;
use App\Modules\BaseAuth\Controllers\ResetPasswordController;
use App\Modules\BaseAuth\Middleware\RedirectIfUserPhoneIsVerfied;
use Illuminate\Support\Facades\Route;

Route::middleware(['web', 'guest'])->group(function () {
    Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
    Route::post('/login', [LoginController::class, 'login']);

    Route::get('/register', [RegisterController::class, 'showNovaRegisterpageForm'])->name('register');
    Route::post('/register', [RegisterController::class, 'register']);

    Route::get('reset-password', [ResetPasswordController::class, 'index'])->name('reset-password');
    Route::post('reset-password', [ResetPasswordController::class, 'store']);
});

Route::middleware(['web', 'auth', RedirectIfUserPhoneIsVerfied::class])->group(function () {
    Route::post('change-phone', [RegisterController::class, 'changePhone'])->name('change-phone');

    Route::post('resend-verification', [RegisterController::class, 'resendVerification'])->name('resend-verification');

    Route::get('sms-verification', [RegisterController::class, 'smsVerification'])
        ->name('sms-verification');

    Route::post('sms-verification', [RegisterController::class, 'verifySmsCode']);
});
