Možnost přidat k objednávce poznámku

This commit is contained in:
2023-06-17 10:44:12 +02:00
parent 26337121de
commit 67242c48df
9 changed files with 97 additions and 24 deletions

View File

@@ -262,4 +262,22 @@ export function updateChoice(login: string, choice: Locations | null) {
}
db.set(today, data);
return data;
}
export function updateNote(login: string, note?: string) {
const today = formatDate(getToday());
let clientData: ClientData = db.get(today);
if (!clientData.pizzaDay) {
throw Error("Pizza day pro dnešní den neexistuje");
}
if (clientData.pizzaDay.state !== PizzaDayState.CREATED) {
throw Error("Pizza day není ve stavu " + PizzaDayState.CREATED);
}
const myOrder = clientData.pizzaDay.orders.find(o => o.customer === login);
if (!myOrder || !myOrder.pizzaList.length) {
throw Error("Pizza day neobsahuje žádné objednávky uživatele " + login);
}
myOrder.note = note;
db.set(today, clientData);
return clientData;
}