feat: Implement Anjungan (Kiosk) module including clinic room selection, various queue pages, patient check-in, and associated admin interfaces.
This commit is contained in:
No files matched your search
+13
-10
@@ -86,12 +86,12 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
isLoadingPatients.value = true;
|
||||
apiPatientsError.value = null;
|
||||
|
||||
// THROTTLE: Check if we recently fetched (within last 5 seconds)
|
||||
// THROTTLE: Check if we recently fetched (within last 2 seconds)
|
||||
const now = Date.now();
|
||||
const lastFetch = lastFetchTime.value[`clinic-${kodeKlinik}`] || 0;
|
||||
const timeSinceLastFetch = now - lastFetch;
|
||||
|
||||
if (timeSinceLastFetch < 5000) {
|
||||
if (timeSinceLastFetch < 2000) {
|
||||
console.log(`⏭️ [queueStore] Skipping fetch for clinic ${kodeKlinik} (last fetched ${Math.round(timeSinceLastFetch/1000)}s ago)`);
|
||||
isLoadingPatients.value = false;
|
||||
return { success: true, message: 'Using cache' };
|
||||
@@ -280,19 +280,20 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
// ============================================
|
||||
const isWsConnected = ref(false);
|
||||
const wsClientId = ref(`client-${Math.random().toString(36).substring(7)}`);
|
||||
const lastGlobalCall = ref(null);
|
||||
|
||||
const onWsMessage = (data) => {
|
||||
const messageData = data?.data || data;
|
||||
const targetLoketId = messageData?.loketId || messageData?.idloket;
|
||||
const targetKlinikId = messageData?.klinikId || messageData?.idklinik;
|
||||
const isTrigger = messageData?.triggerRefresh || targetLoketId || targetKlinikId;
|
||||
|
||||
if (!isTrigger) {
|
||||
// console.log('📨 [queueStore] Global WS Message received (No trigger, skipping refresh)');
|
||||
return;
|
||||
console.log('📨 [queueStore] Global WS Message received:', data);
|
||||
|
||||
// Handle Call Events (cross-device sync for "Sedang Dipanggil" popup)
|
||||
if (messageData?.callEvent) {
|
||||
console.log('📞 [queueStore] Call event received:', messageData.callEvent);
|
||||
lastGlobalCall.value = messageData.callEvent;
|
||||
}
|
||||
|
||||
console.log('📨 [queueStore] Global WS Trigger Message received:', data);
|
||||
|
||||
// TRIGGER STRATEGIC REFRESHES
|
||||
let refreshedSomething = false;
|
||||
@@ -355,6 +356,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
const { connect, disconnect, sendViaPost, isConnected } = useWebSocket({
|
||||
url: wsBaseUrl,
|
||||
clientId: wsClientId,
|
||||
fallbackPostUrl: '/stats-api/ws',
|
||||
onOpen: () => {
|
||||
console.log('✅ [queueStore] WebSocket connected');
|
||||
isWsConnected.value = true;
|
||||
@@ -617,12 +619,12 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
isLoadingPatients.value = true;
|
||||
apiPatientsError.value = null;
|
||||
|
||||
// THROTTLE: Check if we recently fetched (within last 5 seconds)
|
||||
// THROTTLE: Check if we recently fetched (within last 2 seconds)
|
||||
const now = Date.now();
|
||||
const lastFetch = lastFetchTime.value[loketId] || 0;
|
||||
const timeSinceLastFetch = now - lastFetch;
|
||||
|
||||
if (timeSinceLastFetch < 5000 && apiPatientsPerLoket.value[loketId]) {
|
||||
if (timeSinceLastFetch < 2000 && apiPatientsPerLoket.value[loketId]) {
|
||||
console.log(`⏭️ [queueStore] Skipping fetch for loket ${loketId} (last fetched ${Math.round(timeSinceLastFetch/1000)}s ago)`);
|
||||
isLoadingPatients.value = false;
|
||||
return {
|
||||
@@ -3341,6 +3343,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
disconnectWebSocket,
|
||||
isWsConnected,
|
||||
sendViaPost,
|
||||
lastGlobalCall,
|
||||
registerInterest,
|
||||
unregisterInterest,
|
||||
activeLoketInterest,
|
||||
|
||||
Reference in New Issue
Block a user