mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(bug) do not display no price as free
This commit is contained in:
parent
b8db1dc9a9
commit
eb50c37419
@ -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'>
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user