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 @@ - +
Tidak Ada Antrian