Skip to content
Snippets Groups Projects
Commit 117a2c03 authored by Princelle Maxime's avatar Princelle Maxime :gay_pride_flag:
Browse files

:art: improve stock display of prices

parent 392b4aed
Branches
1 merge request!7🔀 V1
......@@ -26,14 +26,14 @@ const Stock = () => {
});
}, []);
let updateProductQuantity = (productId, quantity) => {
const updateProductQuantity = (productId, quantity) => {
let productsTemp = productsList;
let product = productsTemp[productId];
product.stock = quantity;
setProductsList([...productsTemp]);
};
let toggleEditMode = (productId) => {
const toggleEditMode = (productId) => {
let productsTemp = productsList;
let product = productsTemp[productId];
product.edit = product.edit === true ? false : true;
......@@ -45,6 +45,17 @@ const Stock = () => {
}
};
const getPrice = (product: Product):string => {
let price = `${product.price.toFixed(2).replace(".", ",")} €`;
if (product.subscriberPrice !== undefined) {
price += ` / ${product.subscriberPrice.toFixed(2).replace(".", ",")} €`;
} else {
// Display the same price if there is not subscription price
price += ` / ${product.price.toFixed(2).replace(".", ",")} €`;
}
return price;
};
return (
<div className="max-w-7xl mx-auto px-4 sm:px-6 md:px-8">
{rawProductList.length > 0 &&
......@@ -121,7 +132,7 @@ const Stock = () => {
<tr key={product.name} className={productIdx % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
<td className="px-4 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{product.name}</td>
<td className="px-4 py-4 whitespace-nowrap text-sm text-gray-500">{product.category}</td>
<td className="px-4 py-4 whitespace-nowrap text-sm text-gray-500">{product.price.toFixed(2).replace(".", ",")}€ / {product?.subscriberPrice?.toFixed(2).replace(".", ",") ?? product.price.toFixed(2).replace(".", ",")}</td>
<td className="px-4 py-4 whitespace-nowrap text-sm text-gray-500">{getPrice(product)}</td>
<td className="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
{product.edit ?
<input
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment