merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit 1437cf7c97514621001f9a4becad03a9b5ef6056
parent 549d7f20cbb2f559611569466123f3fa2459bb0d
Author: Sebastian <sebasjm@gmail.com>
Date:   Tue, 19 Oct 2021 12:32:06 -0300

do not break when price is zero

Diffstat:
Mpackages/frontend/src/components/product/ProductList.tsx | 9++++++---
Mpackages/frontend/src/declaration.d.ts | 2+-
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/packages/frontend/src/components/product/ProductList.tsx b/packages/frontend/src/components/product/ProductList.tsx @@ -15,7 +15,7 @@ */ import { h, VNode } from "preact" import { MerchantBackend } from "../../declaration" -import { Amounts } from "@gnu-taler/taler-util"; +import { AmountJson, Amounts } from "@gnu-taler/taler-util"; import emptyImage from "../../assets/empty.png"; import { Translate } from "../../i18n"; @@ -42,6 +42,9 @@ export function ProductList({ list, actions = [] }: Props): VNode { </thead> <tbody> {list.map((entry, index) => { + const unitPrice = !entry.price ? '0' : entry.price; + const totalPrice = !entry.price ? '0' : Amounts.stringify(Amounts.mult(Amounts.parseOrThrow(entry.price), entry.quantity).amount); + return <tr key={index}> <td> <img style={{ height: 32, width: 32 }} src={entry.image ? entry.image : emptyImage} /> @@ -50,8 +53,8 @@ export function ProductList({ list, actions = [] }: Props): VNode { <td > {entry.quantity === 0 ? '--' : `${entry.quantity} ${entry.unit}`} </td> - <td >{entry.price}</td> - <td >{Amounts.stringify(Amounts.mult(Amounts.parseOrThrow(entry.price), entry.quantity).amount)}</td> + <td >{unitPrice}</td> + <td >{totalPrice}</td> <td class="is-actions-cell right-sticky"> {actions.map((a, i) => { return <div key={i} class="buttons is-right"> diff --git a/packages/frontend/src/declaration.d.ts b/packages/frontend/src/declaration.d.ts @@ -181,7 +181,7 @@ export namespace MerchantBackend { unit: string; // The price of the product; this is the total price for quantity times unit of this product. - price: Amount; + price?: Amount; // An optional base64-encoded product image image: ImageDataUrl;