diff --git a/kds/kds.js b/kds/kds.js index 4abeb3d..6726317 100644 --- a/kds/kds.js +++ b/kds/kds.js @@ -26,31 +26,48 @@ document.addEventListener('DOMContentLoaded', () => { // Load config from localStorage function loadConfig() { + // Get business ID from portal's shared localStorage (same key portal uses) + const portalBusinessId = localStorage.getItem('payfrit_portal_business'); + if (portalBusinessId && !isNaN(parseInt(portalBusinessId))) { + config.businessId = parseInt(portalBusinessId); + } + + // Load KDS-specific settings const saved = localStorage.getItem('kds_config'); if (saved) { try { const parsed = JSON.parse(saved); - config.businessId = parsed.businessId || null; config.servicePointId = parsed.servicePointId || null; config.stationId = parsed.stationId || null; config.stationName = parsed.stationName || null; config.stationColor = parsed.stationColor || null; config.refreshInterval = (parsed.refreshInterval || 5) * 1000; - - document.getElementById('businessIdInput').value = config.businessId || ''; - document.getElementById('servicePointIdInput').value = config.servicePointId || ''; - document.getElementById('refreshIntervalInput').value = config.refreshInterval / 1000; } catch (e) { console.error('Failed to load config:', e); } } + document.getElementById('businessIdInput').value = config.businessId || ''; + document.getElementById('servicePointIdInput').value = config.servicePointId || ''; + document.getElementById('refreshIntervalInput').value = config.refreshInterval / 1000; + // If no business ID, show config panel if (!config.businessId) { toggleConfig(); } } +function saveConfigToStorage() { + // Save KDS-specific settings only (businessId comes from portal) + localStorage.setItem('kds_config', JSON.stringify({ + servicePointId: config.servicePointId, + stationId: config.stationId, + stationName: config.stationName, + stationColor: config.stationColor, + refreshInterval: config.refreshInterval / 1000 + })); +} + // Check if station selection is needed async function checkStationSelection() { if (!config.businessId) return;