KDS: Read businessId from shared portal localStorage instead of URL params
This commit is contained in:
parent
f51ef7bab2
commit
96e598c6af
1 changed files with 22 additions and 5 deletions
27
kds/kds.js
27
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue