diff --git a/nuxt.config.ts b/nuxt.config.ts index 512277a..0aed299 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -84,7 +84,6 @@ export default defineNuxtConfig({ "@mdi/font/css/materialdesignicons.min.css", "~/assets/scss/main.scss", ], - devServer: (() => { const hostEnv = process.env.HOST || 'localhost'; @@ -103,7 +102,8 @@ export default defineNuxtConfig({ return { port: port, - host: host + host: host, + allowedHosts: ["localhost", "localhost.dev", "10.10.150.175","antrean.dev.rssa.id"] }; })(), diff --git a/pages/Anjungan/AntreanMasuk/[id].vue b/pages/Anjungan/AntreanMasuk/[id].vue index 7dbc6cf..931172d 100644 --- a/pages/Anjungan/AntreanMasuk/[id].vue +++ b/pages/Anjungan/AntreanMasuk/[id].vue @@ -306,6 +306,9 @@ const calledForCheckIn = computed(() => { return [] } + // Normalize loketIds to strings for robust comparison + const normalizedConfiguredIds = loketIds.map(id => String(id)) + return loketPatients.value .filter(p => { // Must be called (waiting status = sudah dipanggil dari status menunggu) @@ -313,8 +316,9 @@ const calledForCheckIn = computed(() => { const isCalled = p.status === 'waiting' && p.processStage === 'loket' // Filter berdasarkan loketId yang dikonfigurasi di screen - const patientLoketId = p.loketId || 1 // Default ke loket 1 jika tidak ada - const isForConfiguredLoket = loketIds.includes(patientLoketId) + // Handle potential undefined or number types + const patientLoketId = String(p.loketId || 1) + const isForConfiguredLoket = normalizedConfiguredIds.includes(patientLoketId) return isCalled && isForConfiguredLoket }) @@ -336,13 +340,14 @@ const displayedLokets = computed(() => { // Group queues by loketId const queuesByLoket = new Map() + const normalizedQueues = Array.isArray(calledForCheckIn.value) ? calledForCheckIn.value : [] loketIds.forEach(loketId => { const loket = masterStore.getLoketById(loketId) - const loketQueues = queues + const loketQueues = normalizedQueues .filter(q => { - const patientLoketId = q.loketId || 1 - return patientLoketId === loketId + // Robust string comparison + return String(q.loketId || 1) === String(loketId) }) .sort((a, b) => { // Sort by createdAt or no for consistent ordering @@ -516,26 +521,38 @@ onMounted(() => { navigateTo('/anjungan/antreanmasuk') return } + + // Proactive Fetching: Ensure this screen fetches data even if others didn't + const fetchAllData = async () => { + console.log('🔄 Anjungan polling: Fetching data for configured lokets...'); + try { + // 1. Fetch data for each configured loket + const loketIds = configuredLoketIds.value; + if (loketIds && loketIds.length > 0) { + for (const id of loketIds) { + await queueStore.fetchPatientsForLoket(id); + } + } + + // 2. Ensure initial data (seeds etc) + queueStore.ensureInitialData(); + + console.log('✅ Anjungan polling: Success'); + } catch (err) { + console.error('❌ Anjungan polling error:', err); + } + }; + + // Initial fetch + fetchAllData(); - // Force reactivity by accessing store data after delays - // This ensures store is fully hydrated after refresh - setTimeout(() => { - // Access loketPatients to trigger computed - const _ = loketPatients.value - // Access calledForCheckIn to trigger computed - const __ = calledForCheckIn.value - // Access displayedLokets to trigger computed - const ___ = displayedLokets.value - }, 100) - - // Additional delay to ensure store hydration is complete - setTimeout(() => { - // Force re-computation by accessing again - const _ = loketPatients.value - const __ = calledForCheckIn.value - const ___ = displayedLokets.value - }, 300) + // Polling every 10 seconds to keep data synchronized + const pollingInterval = setInterval(fetchAllData, 10000); + onUnmounted(() => { + clearInterval(pollingInterval); + }); + updateTime() timeInterval = setInterval(updateTime, 1000) }) diff --git a/pages/Anjungan/AntrianLoket/[id].vue b/pages/Anjungan/AntrianLoket/[id].vue index 321e2b5..fbefd1a 100644 --- a/pages/Anjungan/AntrianLoket/[id].vue +++ b/pages/Anjungan/AntrianLoket/[id].vue @@ -106,9 +106,9 @@ - +
-
DI LOKET (SIAP DIPANGGIL)
+
SIAP DIPANGGIL
+ +
+
TERTUNDA
+
+
+ {{ queue.noAntrian.split(' |')[0] }} +
+
+
+ -
+
mdi-clock-outline

Tidak Ada Antrian

@@ -233,10 +253,10 @@ const loketPatients = computed(() => { const allPatients = queueStore.allPatients?.value || queueStore.allPatients || []; // Filter for this stage and relevant statuses - // Include 'di-loket' (serving/called) and 'waiting' (next in line) + // Include 'di-loket' (serving/called), 'waiting' (next in line) and 'pending' (on hold) return allPatients.filter(p => p.processStage === 'loket' && - (p.status === 'di-loket' || p.status === 'waiting') + (p.status === 'di-loket' || p.status === 'waiting' || p.status === 'pending') ); }); @@ -559,9 +579,11 @@ const displayedClinics = computed(() => { let currentQueue = null const normalizedKlinikName = klinikName.trim() - // Get all checked-in patients for this clinic + // Get all checked-in or pending patients for this clinic const servingQueues = sortedQueues.filter(q => - q.status === 'di-loket' && q.processStage === 'loket' && getKlinikNameFromPatient(q) === normalizedKlinikName + (q.status === 'di-loket' || q.status === 'pending') && + q.processStage === 'loket' && + getKlinikNameFromPatient(q) === normalizedKlinikName ) // Prioritas 1: If Hero section is calling someone for THIS clinic, show them as serving @@ -596,14 +618,16 @@ const displayedClinics = computed(() => { return q.no !== currentQueue?.no }) - // Separate di-loket grid - excluding currentQueue - const diLoketQueuesInGrid = servingQueues.filter(q => q.no !== currentQueue?.no); + // Separate di-loket and pending grids + const diLoketQueuesInGrid = servingQueues.filter(q => q.no !== currentQueue?.no && q.status !== 'pending'); + const pendingQueues = servingQueues.filter(q => q.status === 'pending'); return { name: klinikName, currentQueue: currentQueue, multipleCalls: multipleCalls, diLoketQueues: diLoketQueuesInGrid, + pendingQueues: pendingQueues, // Aded to display pending patients waitingQueues: [], // Removed as per request allQueues: diLoketQueuesInGrid, totalQueues: servingQueues.length @@ -613,13 +637,12 @@ const displayedClinics = computed(() => { return clinics.sort((a, b) => a.name.localeCompare(b.name)) }) -// Dynamic grid logic: divide total by 2 to balance across rows, cap at 7 +// Dynamic grid logic: divide total by 2 to balance across rows, cap at 5 for larger cards const gridColumns = computed(() => { const total = displayedClinics.value.length if (total <= 1) return 1 - if (total <= 7) return total // Show in one row if 7 or less looks better? - // User asked for balanced rows, so for 8 clinics it will be 4 col, 2 rows. - return Math.min(7, Math.ceil(total / 2)) + if (total <= 5) return total + return Math.min(5, Math.ceil(total / 2)) }) const gridStyle = computed(() => ({ @@ -897,10 +920,10 @@ onUnmounted(() => {