doc: add useStateValue and getBasketTotal
This commit is contained in:
1 parent
d64671d0f5
commit
7c6ee1d588
1 file changed
+5
-2
@@ -1,15 +1,18 @@
|
||||
import React from "react";
|
||||
import CurrencyFormat from "react-currency-format";
|
||||
import { useStateValue } from "../redux/StateProvider";
|
||||
import { getBasketTotal } from "../redux/reducer";
|
||||
import "./Subtotal.css";
|
||||
|
||||
function Subtotal() {
|
||||
const [{ basket }, dispatch] = useStateValue();
|
||||
return (
|
||||
<section className="subtotal">
|
||||
<CurrencyFormat
|
||||
renderText={(value) => (
|
||||
<>
|
||||
<p>
|
||||
Subtotal (0 items): <strong>0</strong>
|
||||
Subtotal ({basket.length} items): <strong>{value}</strong>
|
||||
</p>
|
||||
<small className="subtotal__gift">
|
||||
<input type="checkbox" /> This order contains a gift
|
||||
@@ -17,7 +20,7 @@ function Subtotal() {
|
||||
</>
|
||||
)}
|
||||
decimalScale={2}
|
||||
value={0}
|
||||
value={getBasketTotal(basket)}
|
||||
displayType={"text"}
|
||||
thousandSeparator={true}
|
||||
prefix={"$"}
|
||||
|
||||
Reference in new issue
Block a user