Post marche pas
This commit is contained in:
@@ -84,13 +84,18 @@ const InvoiceItem = ({ invoice }) => {
|
||||
|
||||
<div className="invoice-item-container">
|
||||
<div className="invoice-item-info">
|
||||
<div>
|
||||
#{invoice.id} ({getStatus(invoice.status)})
|
||||
</div>
|
||||
{invoice.status != null ?
|
||||
<div>
|
||||
#{invoice.id} ({getStatus(invoice.status)})
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
<div className="invoice-item-expedition">
|
||||
<b>Adresse d'expédition:</b><br />
|
||||
{invoice.firstName} {invoice.lastName}<br />
|
||||
{invoice.shippingAddress.civicNumber} {invoice.shippingAddress.street}<br />
|
||||
{invoice.shippingAddress.civicNumber} {invoice.shippingAddress.street} <br />
|
||||
{invoice.shippingAddress.appartment != null ? <>App: {invoice.shippingAddress.appartment} <br /></> : null}
|
||||
{invoice.shippingAddress.city}, {invoice.shippingAddress.province} {invoice.shippingAddress.postalCode}<br />
|
||||
{invoice.shippingAddress.country}<br />
|
||||
</div>
|
||||
@@ -99,7 +104,7 @@ const InvoiceItem = ({ invoice }) => {
|
||||
<h4>Produits</h4>
|
||||
<ul className="invoice-item-product-list">
|
||||
{invoice.products.map((p) => (
|
||||
<li key={p.id}>{p.quantity} x {p.product.title} <br/> <b>{productTotal(p).toFixed(2)} $ CA</b></li>
|
||||
<li key={p.id}>{p.quantity} x {p.product.title} <br /> <b>{productTotal(p).toFixed(2)} $ CA</b></li>
|
||||
))}
|
||||
</ul>
|
||||
<>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
const ReviewProdItem = ({ pq, onAddOne, onRemoveOne, onRemoveProduct }) => {
|
||||
export function ReviewProdItem({ pq, /*onAddOne, onRemoveOne, onRemoveProduct*/ }) {
|
||||
|
||||
const productTotal = (p) => {
|
||||
return (p.quantity * (p.status == 3 || p.status == 4 ? p.promoPrice : p.price))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="review-prod-item-container">
|
||||
|
||||
</div>
|
||||
|
||||
<div className="invoice-item-product" key={pq.id}>{pq.quantity} x {pq.title} <br /> <b>{productTotal(pq).toFixed(2)} $ CA</b></div>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
import ReviewProdItem from "./ReviewProdItem";
|
||||
import { CartContext } from './Cart';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function ReviewProdList(/*{ products , onAddOne, onRemoveOne, onRemoveProduct }*/) {
|
||||
const cart = useContext(CartContext);
|
||||
|
||||
const ReviewProdList = ({ products, onAddOne, onRemoveOne, onRemoveProduct }) => {
|
||||
return (
|
||||
<div>
|
||||
{products.map((p) => (
|
||||
<ReviewProdItem
|
||||
key={p.product.id}
|
||||
pq={p}
|
||||
onAddOne={onAddOne}
|
||||
onRemoveOne={onRemoveOne}
|
||||
onRemoveProduct={onRemoveProduct}
|
||||
/>
|
||||
))}
|
||||
<div className="invoice-item-products">
|
||||
<h3>Produits</h3>
|
||||
<div className="invoice-item-product-list">
|
||||
{cart.items.map((p) => (
|
||||
<ReviewProdItem
|
||||
key={p.id}
|
||||
pq={p}
|
||||
//onAddOne={onAddOne}
|
||||
//onRemoveOne={onRemoveOne}
|
||||
//onRemoveProduct={onRemoveProduct}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
|
||||
@@ -1,38 +1,45 @@
|
||||
const TotalProductsPrice = ({ products }) => {
|
||||
import { CartContext } from './Cart';
|
||||
import { useContext } from 'react';
|
||||
|
||||
const productTotal = (p) => {
|
||||
return (p.quantity * (p.product.status == 3 || p.product.status == 4 ? p.product.promoPrice : p.product.price))
|
||||
}
|
||||
export function TotalProductsPrice(/*{ products }*/) {
|
||||
|
||||
const getPriceHTML = (prods) => {
|
||||
const cart = useContext(CartContext);
|
||||
|
||||
// const productTotal = (p) => {
|
||||
// return (p.quantity * (p.product.status == 3 || p.product.status == 4 ? p.product.promoPrice : p.product.price))
|
||||
// }
|
||||
|
||||
const getPriceHTML = (/*prods*/) => {
|
||||
|
||||
const tpsRate = 5;
|
||||
const tvqRate = 9.975;
|
||||
|
||||
var price = 0;
|
||||
var price = cart.getTotalCost();
|
||||
var tps = 0;
|
||||
var tvq = 0;
|
||||
var total;
|
||||
|
||||
prods.map((p) => {
|
||||
price += productTotal(p);
|
||||
});
|
||||
// prods.map((p) => {
|
||||
// price += productTotal(p);
|
||||
// });
|
||||
|
||||
tps = price * (tpsRate / 100);
|
||||
tvq = price * (tvqRate / 100);
|
||||
total = price + tps + tvq;
|
||||
|
||||
return (
|
||||
<div className="invoice-item-price">
|
||||
Sous-total = {price.toFixed(2)} $ CA<br />
|
||||
+ TPS ({tpsRate}%) = {tps.toFixed(2)} $ CA<br />
|
||||
+ TVQ ({tvqRate}%) = {tvq.toFixed(2)} $ CA<br />
|
||||
<b>Total = {(price + tps + tvq).toFixed(2)} $ CA</b>
|
||||
<b>Total = {total.toFixed(2)} $ CA</b>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{getPriceHTML(products)}
|
||||
{getPriceHTML(/*products*/)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user