<?php

use Modules\Client\Http\Controllers\Api\AuthController;
use Modules\Client\Http\Controllers\Api\CorporateDivisionController;
use Modules\Client\Http\Controllers\Api\CorporateManageController;
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
use Modules\Client\Http\Controllers\Api\CorporateCurrentController;
use Modules\Client\Http\Controllers\Api\MemberController;
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
use Modules\Client\Http\Controllers\Api\UserController;
use Modules\Client\Http\Controllers\Api\ClaimController;
use Modules\Client\Http\Controllers\Api\TopUpController;
use Modules\Internal\Http\Controllers\ClaimEncounterController;
use Modules\Client\Http\Controllers\Api\ClaimReportController;
use Modules\Client\Http\Controllers\Api\ClaimRequestController;
use Modules\Client\Http\Controllers\Api\DataController;

/*
|--------------------------------------------------------------------------
| 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::prefix('client')->group(function () {

    Route::controller(AuthController::class)->group(function () {
        Route::post('login', 'login');
        Route::post('verify-code', 'validateOtp');
    });

    Route::middleware('auth:sanctum')->group(function () {
        Route::post('logout', [AuthController::class, 'logout'])->name('logout');
        Route::get('user', [UserController::class, 'index']);
        Route::get('data/{id}', [DataController::class, 'show']);
        Route::put('data/{id}', [DataController::class, 'update']);
        Route::post('update-family', [DataController::class, 'updateFamily']);

        Route::get('corporate-manage', [CorporateManageController::class, 'index']);
        Route::get('corporate-manage/{corporate_id}', [CorporateManageController::class, 'show']);
        Route::prefix('{corporate_id}')->group(function () {
            Route::post('search-member', [MemberController::class, 'index']);
            Route::get('policy', [CorporatePolicyController::class, 'index']);
            Route::get('division', [CorporateDivisionController::class, 'index']);
            Route::get('members', [CorporateMemberController::class, 'index']);
            Route::get('members/{id}', [CorporateMemberController::class, 'show']);
            Route::get('export-members/list', [CorporateMemberController::class, 'generateMemberList']);
            Route::get('alarm-center-members/{id}', [CorporateMemberController::class, 'showPerMember']);
            Route::get('service-monitoring/{request_log_id}', [CorporateMemberController::class, 'serviceMonitoring']);
            Route::get('claims/status', [ClaimController::class, 'status']);
            Route::get('claims', [ClaimController::class, 'index']);
            Route::get('claims/export', [ClaimController::class, 'export']);
            Route::get('claims/exportAlrmCenter/{start}/{end}', [ClaimController::class, 'exportAlrmCenter']);
            Route::get('claims/{claim_id}/encounters', [ClaimEncounterController::class, 'getEncounterData']);
            Route::get('topup', [TopUpController::class, 'index']);
            // Route::get('topup', [TopUpController::class, 'get']);
            Route::post('topup', [TopUpController::class, 'store']);
            Route::get('claim-report/claim-status', [ClaimReportController::class, 'claimStatus']);
            Route::get('claim-report/detail/{id}', [ClaimReportController::class, 'claimDetail']);
            Route::get('claim-report/detail-history/{id}', [ClaimReportController::class, 'claimDetailHistory']);
            Route::post('claim-report/{id}/request-files', [ClaimReportController::class, 'requestFiles']);

            Route::get('corporate', [CorporateCurrentController::class, 'index']);
            Route::put('corporate-update', [CorporateCurrentController::class, 'update']);
        });
        Route::get('claims/{id}', [ClaimController::class, 'show']);

        Route::post('claim-requests', [ClaimRequestController::class, 'store'])->name('claim-requests.store');
        Route::post('claim-requests/{id}', [ClaimRequestController::class, 'show'])->name('claim-requests.show');
    });
});
