KDS: Read businessId from shared portal localStorage instead of URL params

This commit is contained in:
John Mizerek 2026-01-18 13:15:08 -08:00
parent f51ef7bab2
commit 96e598c6af

View file

@ -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;