<?php

use Illuminate\Http\Request;
use Modules\HospitalPortal\Http\Controllers\Api\AuthController;
use Modules\HospitalPortal\Http\Controllers\Api\ClaimRequestController;
use Modules\HospitalPortal\Http\Controllers\Api\MemberController;
use Modules\HospitalPortal\Http\Controllers\ClaimController;
use Modules\HospitalPortal\Http\Controllers\Api\NotificationController;
use Modules\HospitalPortal\Http\Controllers\Api\RequestLogController;
use Modules\HospitalPortal\Http\Middleware\Authentication;
use Modules\HospitalPortal\Http\Middleware\Authorization;

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

        Route::middleware(Authentication::class)->group(function () {
            Route::controller(AuthController::class)->group(function () {
                Route::post('login', 'login');
            });
        });
        
        //Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
        //Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');


        Route::middleware('auth:sanctum')->group(function () {

            Route::post('logout', [AuthController::class, 'logout'])->name('logout');
            Route::get('/user', function (Request $request) {
                return $request->user();
            });
            Route::put('reset-password', [AuthController::class, 'resetPassword'])->name('resetPassword');

            Route::get('claims', [ClaimController::class, 'index']);

            Route::middleware(Authorization::class)->group(function () {
                //Search Member
                Route::controller(MemberController::class)->group(function () {
                    Route::post('search-member', 'search');
                });
                // Request LOG
                Route::controller(RequestLogController::class)->group(function () {
                    Route::post('request-log', 'requestLog');
                    Route::get('get-request-log', 'getRequestLog');
                    Route::get('get-final-log', 'getFinalLog');
                    Route::post('request-final-log', 'requestFinalLog');
                    Route::get('download-log/{request_log_id}', 'downlodLog');
                    Route::get('download-final-log/{request_log_id}', 'downlodFinalLog');
                });
                //Notification
                Route::controller(NotificationController::class)->group(function() {
                    //get notifications
                    Route::get('notifications/{user_id}', 'getNotifications');
                    //Set read notification
                    Route::post('set-read-notification', 'setReadNotification');
                });
            });
            // Request Final LOG
            Route::controller(RequestLogController::class)->group(function () {
                Route::post('request-final-log', 'requestFinalLog');
            });
            // Claim Submit
            Route::controller(ClaimRequestController::class)->group(function () {
                Route::post('claim-requests', 'store');
            });
            Route::get('claim-requests', [ClaimRequestController::class, 'index'])->name('claim-requests.index');
            // Route::post('claim-requests', [ClaimRequestController::class, 'store'])->name('claim-requests.store');
            Route::get('claim-requests/{claim_request_id}/log', [ClaimRequestController::class, 'generateLog'])->name('claim-requests.generate-log');
            Route::get('claim-requests/{id}', [ClaimRequestController::class, 'show'])->name('claim-requests.show');
            Route::get('get-claim-requests', [ClaimRequestController::class, 'get_claim_requests'])->name('claim-requests.get_claim_requests');
            Route::get('detail-claim-requests/{id}', [ClaimRequestController::class, 'detail_claim_requests'])->name('claim-requests.detail_claim_requests');
            Route::post('claim-requests/{id}/request-files', [ClaimRequestController::class, 'requestFiles']);
        });
    });
});
