This commit is contained in:
@@ -128,11 +128,11 @@ export async function removePizzaOrder(login: string, pizzaOrder: PizzaVariant)
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
const orderIndex = clientData.pizzaDay!.orders!.findIndex(o => o.customer === login);
|
||||
const orderIndex = clientData.pizzaDay.orders!.findIndex(o => o.customer === login);
|
||||
if (orderIndex < 0) {
|
||||
throw Error("Nebyly nalezeny žádné objednávky pro uživatele " + login);
|
||||
}
|
||||
const order = clientData.pizzaDay!.orders![orderIndex];
|
||||
const order = clientData.pizzaDay.orders![orderIndex];
|
||||
const index = order.pizzaList!.findIndex(o => o.name === pizzaOrder.name && o.size === pizzaOrder.size);
|
||||
if (index < 0) {
|
||||
throw Error("Objednávka s danými parametry nebyla nalezena");
|
||||
@@ -308,7 +308,7 @@ export async function updatePizzaFee(login: string, targetLogin: string, text?:
|
||||
targetOrder.fee = { text, price };
|
||||
}
|
||||
// Přepočet ceny
|
||||
targetOrder.totalPrice = targetOrder.pizzaList.reduce((price, pizzaOrder) => price + pizzaOrder.price, 0) + (targetOrder.fee?.price || 0);
|
||||
targetOrder.totalPrice = targetOrder.pizzaList.reduce((price, pizzaOrder) => price + pizzaOrder.price, 0) + (targetOrder.fee?.price ?? 0);
|
||||
await storage.setData(today, clientData);
|
||||
return clientData;
|
||||
}
|
||||
Reference in New Issue
Block a user