Reset KDS station filter on business change, add default Kitchen station
KDS was keeping the station filter from a previous business in localStorage, causing orders to be hidden when switching businesses. Now tracks businessId and resets station selection on change. New businesses also get a default "Kitchen" station so the KDS works out of the box. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c79a750a50
commit
d80d4bd4c4
2 changed files with 21 additions and 3 deletions
|
|
@ -344,6 +344,15 @@ try {
|
|||
}
|
||||
response.steps.append("Created 7 default task categories");
|
||||
|
||||
// Create default kitchen station
|
||||
queryTimed("
|
||||
INSERT INTO Stations (BusinessID, Name, Color, SortOrder)
|
||||
VALUES (:businessID, 'Kitchen', '##FF9800', 1)
|
||||
", {
|
||||
businessID: { value: businessId, cfsqltype: "cf_sql_integer" }
|
||||
}, { datasource: "payfrit" });
|
||||
response.steps.append("Created default Kitchen station");
|
||||
|
||||
// Save business hours from structured schedule
|
||||
if (structKeyExists(biz, "hoursSchedule") && isArray(biz.hoursSchedule)) {
|
||||
hoursSchedule = biz.hoursSchedule;
|
||||
|
|
|
|||
|
|
@ -59,9 +59,17 @@ function loadConfig() {
|
|||
if (saved) {
|
||||
try {
|
||||
const parsed = JSON.parse(saved);
|
||||
// Reset station selection if business changed since last KDS use
|
||||
if (parsed.businessId && parsed.businessId !== config.businessId) {
|
||||
config.stationId = null;
|
||||
config.stationName = null;
|
||||
config.stationColor = null;
|
||||
saveConfigToStorage();
|
||||
} else {
|
||||
config.stationId = parsed.stationId !== undefined ? parsed.stationId : null;
|
||||
config.stationName = parsed.stationName || null;
|
||||
config.stationColor = parsed.stationColor || null;
|
||||
}
|
||||
config.refreshInterval = (parsed.refreshInterval || 5) * 1000;
|
||||
} catch (e) {
|
||||
console.error('[KDS] Failed to load config:', e);
|
||||
|
|
@ -73,6 +81,7 @@ function loadConfig() {
|
|||
|
||||
function saveConfigToStorage() {
|
||||
localStorage.setItem('kds_config', JSON.stringify({
|
||||
businessId: config.businessId,
|
||||
stationId: config.stationId,
|
||||
stationName: config.stationName,
|
||||
stationColor: config.stationColor,
|
||||
|
|
|
|||
Reference in a new issue