From e686ddad57a4ac7bce0b83c9f84761a9303df29d Mon Sep 17 00:00:00 2001 From: Fanrouver Date: Tue, 10 Feb 2026 10:10:56 +0700 Subject: [PATCH] fix socket checkin --- pages/CheckInPasien/checkIn.vue | 15 +++++++++++++++ stores/queueStore.js | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/pages/CheckInPasien/checkIn.vue b/pages/CheckInPasien/checkIn.vue index 2f956d6..bbc0aa2 100644 --- a/pages/CheckInPasien/checkIn.vue +++ b/pages/CheckInPasien/checkIn.vue @@ -1779,6 +1779,7 @@ const checkInClientId = computed(() => { const fetchAllData = async () => { console.log('🔄 CheckIn refresh: Syncing data...'); try { + await queueStore.fetchAllPatients(); queueStore.ensureInitialData(); checkAndResetDaily(); console.log('✅ CheckIn refresh: Success'); @@ -3354,6 +3355,13 @@ const checkInManual = async () => { kodeKlinik: null, }); + // RESET lastCheckInResult for failure to avoid success color bleed + lastCheckInResult.value = { + success: false, + patientId: searchBarcode || inputValue, + status: "NOT_FOUND", + }; + const errorMsg = `❌ Tiket Tidak Ditemukan!\n\nInput: ${inputValue}\n\nTiket dengan nomor antrean atau barcode tersebut tidak ditemukan di sistem.\n\nPastikan:\n- Nomor antrean atau barcode sudah benar\n- Tiket sudah di-generate terlebih dahulu\n- Format input: RA020, F-RA001, atau 26011500001`; infoMessage.value = errorMsg; infoAction.value = "checkin"; @@ -3414,6 +3422,13 @@ const checkInManual = async () => { kodeKlinik: foundPatient.kodeKlinik || null, }); + // RESET lastCheckInResult for failure + lastCheckInResult.value = { + success: false, + patientId: foundPatient.barcode, + status: "REFRESH_NOT_FOUND", + }; + const errorMsg = `❌ Pasien tidak ditemukan di sistem setelah refresh data.`; infoMessage.value = errorMsg; infoAction.value = "checkin"; diff --git a/stores/queueStore.js b/stores/queueStore.js index d296dd9..43955cd 100644 --- a/stores/queueStore.js +++ b/stores/queueStore.js @@ -447,6 +447,22 @@ export const useQueueStore = defineStore('queue', () => { } }; + /** + * Global fetcher for all patients across all available lokets + */ + const fetchAllPatients = async () => { + console.log('🔄 [queueStore] Fetching all patients for all lokets...'); + const allLokets = loketStore.lokets || []; + if (allLokets.length === 0) { + console.warn('⚠️ [queueStore] No lokets available for fetchAllPatients'); + return; + } + + // Use Promise.all for faster fetching + await Promise.all(allLokets.map(l => fetchPatientsForLoket(l.id))); + console.log(`✅ [queueStore] All patients fetched. Total: ${allPatients.value.length}`); + }; + /** * Get patients for a specific loket (from API or seed data based on loket type) */ @@ -2549,6 +2565,7 @@ export const useQueueStore = defineStore('queue', () => { // API Patient Actions fetchPatientsForLoket, + fetchAllPatients, getPatientsForLoket, mapStatusFromDeskripsi, mapApiPatientToStoreFormat,