<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\RegionController;
use App\Http\Middleware\EnsurePhoneIsVerified;
use App\Http\Controllers\Api\ProfileController;

// Auth
Route::prefix('auth')->group(function () {
    // Registration
    Route::post('/register', [AuthController::class, 'register']);

    // Login
    Route::post('/login', [AuthController::class, 'login']);

    // Password recovery
    Route::post('/password/recovery', [AuthController::class, 'passwordRecoveryForgot']);
    Route::post('/password/recovery/check', [AuthController::class, 'passwordRecoveryCheck']);
    Route::post('/password/recovery/reset', [AuthController::class, 'passwordRecoveryReset']);

    // Verification
    Route::post('/verification', [AuthController::class, 'identifierVerificationRequest']);
    Route::post('/verification/activate', [AuthController::class, 'identifierVerificationActive']);

    // Logout
    Route::get('/logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
});

// Profile
Route::prefix('profile')->middleware(['auth:sanctum', EnsurePhoneIsVerified::class])->group(function () {
    // Me
    Route::get('/me', [ProfileController::class, 'me']);

    // Update
    Route::patch('/', [ProfileController::class, 'update']);
});

// Regions
Route::get('/regions', [RegionController::class, 'index']);
