doc: add moment, CheckoutProduct and CurrencyFormat

This commit is contained in:
Leon Xu
2022-05-07 15:45:44 -07:00
parent 2bd6b8c44d
commit a7e7f90975
+33 -2
View File
@@ -1,8 +1,39 @@
import React from "react";
import moment from "moment";
import CheckoutProduct from "../CheckoutProduct";
import CurrencyFormat from "react-currency-format";
import "./Order.css";
function Order() {
return <section>Order</section>;
function Order({ order }) {
return (
<div className="order">
<h2>Order</h2>
<p>{moment.unix(order.data.created).format("MMMM Do YYYY, h:mma")}</p>
<p className="order__id">
<small>{order.id}</small>
</p>
{order.data.basket?.map((item) => (
<CheckoutProduct
id={item.id}
title={item.title}
image={item.image}
price={item.price}
rating={item.rating}
hideButton
/>
))}
<CurrencyFormat
renderText={(value) => (
<h3 className="order__total">Order Total: {value}</h3>
)}
decimalScale={2}
value={order.data.amount / 100}
displayType={"text"}
thousandSeparator={true}
prefix={"$"}
/>
</div>
);
}
export default Order;