1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

(bug) do not display no price as free

This commit is contained in:
Sylvain 2022-09-28 10:33:30 +02:00
parent b8db1dc9a9
commit eb50c37419
2 changed files with 6 additions and 6 deletions

View File

@ -1,11 +1,11 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import FormatLib from '../../lib/format';
import { FabButton } from '../base/fab-button';
import { Product } from '../../models/product';
import { PencilSimple, Trash } from 'phosphor-react';
import noImage from '../../../../images/no_image.png';
import { FabStateLabel } from '../base/fab-state-label';
import { ProductPrice } from './product-price';
interface ProductItemProps {
product: Product,
@ -76,10 +76,7 @@ export const ProductItem: React.FC<ProductItemProps> = ({ product, onEdit, onDel
<span>{t('app.admin.store.product_item.stock.external')}</span>
<p>{product.stock.external}</p>
</div>
<div className='price'>
<p>{FormatLib.price(product.amount || 0)}</p>
<span>/ {t('app.admin.store.product_item.unit')}</span>
</div>
<ProductPrice product={product} className="price" />
</div>
<div className='actions'>
<div className='manage'>

View File

@ -18,9 +18,12 @@ export const ProductPrice: React.FC<ProductPriceProps> = ({ product, className }
* Return the formatted price data
*/
const renderPrice = (product: Product) => {
if ([0, null, undefined].includes(product.amount)) {
if (product.amount === 0) {
return <p>{t('app.public.product_price.free')}</p>;
}
if ([null, undefined].includes(product.amount)) {
return <div/>;
}
return <>
<p>{FormatLib.price(product.amount)}</p>
<span>{t('app.public.product_price.per_unit')}</span>