<?php

use Illuminate\Support\Facades\Route;
use Modules\Patient\Http\Controllers\PatientController;
use Modules\Patient\Http\Controllers\PatientControllerLookupController;
use Modules\Patient\Http\Controllers\ZakatFundController;
use Modules\Patient\Http\Controllers\SyncController;

Route::middleware(['api.auth'])->group(function () {

    Route::prefix('patients-management')->group(function () {
        Route::apiResource('patients', PatientController::class)->names('patients')->only(['index', 'show']);
        Route::apiResource('zakat-fund', ZakatFundController::class)->names('zakat-fund')->except('destroy');
        Route::patch('zakat-fund/{zakatFund}/status', [ZakatFundController::class, 'updateStatus'])->name('zakat-fund.update-status');
        Route::post('zakat-fund/reorder', [ZakatFundController::class, 'reorder'])->name('zakat-fund.reorder');
        Route::get('zakat/sync-pending', [ZakatFundController::class, 'syncAllPending'])->name('zakat.sync_pending');
    });

    Route::prefix('patients-management/lookups')->group(function () {
        Route::get('patients', [PatientControllerLookupController::class, 'patientList']);
        Route::get('zakat-funds', [PatientControllerLookupController::class, 'zakatFundList']);
    });
});

//pms hit this api to sync data from pms to erp
Route::post('zakat-fund/sync-from-erp', [SyncController::class, 'handleSyncZakatFund'])->name('zakat.sync_from_erp');
Route::post('patients/sync-from-erp', [SyncController::class, 'handleSyncPatients'])->name('patients.sync_from_erp');
