Download amazon-clone/src/Subtotal.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Subtotal.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Subtotal.js
-
curl -L -o Subtotal.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Subtotal.js
1.17 kB
| import React from "react"; | |
| import "./Subtotal.css"; | |
| import CurrencyFormat from "react-currency-format"; | |
| import { useStateValue } from "./StateProvider"; | |
| import { getBasketTotal } from "./reducer"; | |
| import { useHistory } from "react-router-dom"; | |
| function Subtotal() { | |
| const history = useHistory(); | |
| const [{ basket, drawer }, dispatch] = useStateValue(); | |
| return ( | |
| <div className="subtotal"> | |
| <CurrencyFormat | |
| renderText={(value) => ( | |
| <> | |
| <p> | |
| Subtotal ({basket.length} items): <strong>{value}</strong> | |
| </p> | |
| <small className="subtotal__gift"> | |
| <input type="checkbox" /> This order contains a gift | |
| </small> | |
| </> | |
| )} | |
| decimalScale={2} | |
| value={getBasketTotal(basket)} | |
| displayType="text" | |
| thousandSeparator={true} | |
| prefix={"$"} | |
| /> | |
| <button | |
| onClick={(e) => { | |
| dispatch({ | |
| type: "SET_DRAWER", | |
| toggle: false, | |
| }); | |
| history.push("/payment"); | |
| }} | |
| > | |
| Proceed to checkout | |
| </button> | |
| </div> | |
| ); | |
| } | |
| export default Subtotal; | |