<?php

use App\Http\Controllers\API\v1\CustomerController;
use App\Http\Controllers\API\v1\VoucherController;
use App\Http\Controllers\API\v1\AuthController;
use App\Http\Middleware\CheckStatus;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::prefix('v1')->group(function () {
    Route::prefix('auth')->group(function () {
        Route::post('login', [AuthController::class, 'login']);
        // Route::post('logout', [AuthController::class, 'logout'])->middleware(['auth:sanctum']);
    });
    Route::middleware([CheckStatus::class])->group(function () {
        Route::get('member', [CustomerController::class, 'index']);
        Route::get('member/voucher', [VoucherController::class, 'index']);
        Route::get('voucher', [VoucherController::class, 'index']);
        Route::post('voucher/burn', [VoucherController::class, 'burn']);
        Route::post('transaction', [VoucherController::class, 'transaction']);
    });
});
