From 1b132a7ca74ab337f8fa8774490d929e2c0b7f36 Mon Sep 17 00:00:00 2001 From: Martin Berka Date: Fri, 22 Sep 2023 20:30:27 +0200 Subject: [PATCH] =?UTF-8?q?Oprava=20generov=C3=A1n=C3=AD=20QR=20k=C3=B3d?= =?UTF-8?q?=C5=AF=20pro=20Pizza=20day?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/App.css | 1 + client/src/App.tsx | 8 +++----- server/src/service.ts | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/App.css b/client/src/App.css index aa245db..fb087e5 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -107,6 +107,7 @@ .qr-code { text-align: center; + margin-top: 30px; } .select-search-container { diff --git a/client/src/App.tsx b/client/src/App.tsx index 19d6bc2..5bcda7a 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -368,8 +368,7 @@ function App() { Poslední změny: {dayIndex != null && @@ -548,7 +547,7 @@ function App() { { data.pizzaDay.state === PizzaDayState.DELIVERED &&
-

Pizzy byly doručeny. Objednávku můžete uhradit pomocí QR kódu níže.

+

{`Pizzy byly doručeny.${myOrder?.hasQr ? ` Objednávku můžete uživateli ${data.pizzaDay.creator} uhradit pomocí QR kódu níže.` : ''}`}

} @@ -578,9 +577,8 @@ function App() { data.pizzaDay.state === PizzaDayState.DELIVERED && myOrder?.hasQr &&

QR platba

-
Částka: {myOrder.totalPrice} Kč
QR kód -

Generování QR kódů je v experimentální fázi - doporučujeme si překontrolovat údaje před odesláním platby.

+

Pozor, QR kód nezohledňuje případné přidané ingredience.

} diff --git a/server/src/service.ts b/server/src/service.ts index af8fbd4..04cd317 100644 --- a/server/src/service.ts +++ b/server/src/service.ts @@ -319,13 +319,13 @@ export async function finishPizzaDelivery(login: string, bankAccount?: string, b clientData.pizzaDay.state = PizzaDayState.DELIVERED; // Vygenerujeme QR kód, pokud k tomu máme data - // TODO berka je potřeba počkat na resolve promises z generateQr a až poté volat save do DB if (bankAccount?.length && bankAccountHolder?.length) { for (const order of clientData.pizzaDay.orders) { if (order.customer !== login) { // zatím platí creator = objednávající, a pro toho nemá QR kód smysl let message = order.pizzaList.map(pizza => `Pizza ${pizza.name} (${pizza.size})`).join(', '); const price = order.pizzaList.map(pizza => pizza.price).reduce((partial, a) => partial + a, 0); - generateQr(order.customer, bankAccount, bankAccountHolder, price, message).then(() => order.hasQr = true); + await generateQr(order.customer, bankAccount, bankAccountHolder, price, message); + order.hasQr = true; } } }