"use client"; import { Box, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material'; import React from 'react'; import { useTranslation } from 'react-i18next'; import CustomCard from '@molecules/CustomCard'; import UserHeader from '@molecules/UserHeader'; interface Product { id: number; amount: number; name: string; unitValue: number; tax: number; discount: number; total: number; } interface ProductTableProps { products: Product[]; } const ProductTable: React.FC = ({ products }) => { const totalAmount = products.reduce((acc, product) => acc + product.amount, 0); const totalUnitValue = products.reduce((acc, product) => acc + product.unitValue * product.amount, 0); const totalTax = products.reduce((acc, product) => acc + product.tax, 0); const totalDiscount = products.reduce((acc, product) => acc + product.discount, 0); const grandTotal = products.reduce((acc, product) => acc + product.total, 0); const { t } = useTranslation() return ( {t("tle_amount")} {t("tle_product")} {t("tle_unit_value")} {t("tle_tax")} {t("tle_discount")} {t("tle_total")} {products.map((product) => ( {product.amount} {product.name} ${product.unitValue.toFixed(2)} ${product.tax.toFixed(2)} ${product.discount.toFixed(2)} ${product.total.toFixed(2)} ))}
{t("tle_item_count")} {t("tle_total_unit")} {t("tle_total_taxes")} {t("tle_total_discount")} {t("tle_total")} {totalAmount} ${totalUnitValue.toFixed(2)} ${totalTax.toFixed(2)} ${totalDiscount.toFixed(2)} ${grandTotal.toFixed(2)}
); }; export default ProductTable;