import { faTimes } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { weight } from "fontawesome"; const InvoiceItem = ({ invoice, onCancel, paymentInfos }) => { const productTotal = (p) => { return (p.quantity * (p.product.status == 3 || p.product.status == 4 ? p.product.promoPrice : p.product.price)) } const getPriceHTML = () => { const tpsRate = 5; const tvqRate = 9.975; var price = 0; var tps = 0; var tvq = 0; invoice.products.map((p) => { price += productTotal(p); }); tps = price * (tpsRate / 100); tvq = price * (tvqRate / 100); return (
Sous-total = {price.toFixed(2)} $ CA
+ TPS ({tpsRate}%) = {tps.toFixed(2)} $ CA
+ TVQ ({tvqRate}%) = {tvq.toFixed(2)} $ CA
Total = {(price + tps + tvq).toFixed(2)} $ CA
); } const getStatus = (statusCode) => { switch (statusCode) { case 0: return ( <> Confirmé ) case 1: return ( <> Cancellé ) case 2: return ( <> En préparation ) case 3: return ( <> En expédition ) case 4: return ( <> Expédié ) case 5: return ( <> Retourné ) default: return ( <> Status Invalide ) } } console.log(invoice); return (
{invoice.status != null ?
#{invoice.id} ({getStatus(invoice.status)})
: null }
Adresse d'expédition :
{invoice.firstName} {invoice.lastName}
{invoice.shippingAddress.civicNumber} {invoice.shippingAddress.street}
{invoice.shippingAddress.appartment != null ? <>App: {invoice.shippingAddress.appartment}
: null} {invoice.shippingAddress.city}, {invoice.shippingAddress.province} {invoice.shippingAddress.postalCode}
{invoice.shippingAddress.country}

{paymentInfos == true && invoice.payment != null ? <>
Nom : {invoice.payment.name}
Email : {invoice.payment.email}
Téléphone : {invoice.payment.phone}
Numéro de carte : **** **** **** {invoice.payment.lastFourDigits}
: null }

Produits

{(invoice.status == 0 || invoice.status == 2 )&&

onCancel(invoice.id)} />

}
<> {getPriceHTML()}
); } export default InvoiceItem;