Devendra174's picture
Upload folder using huggingface_hub
f5071ca verified
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;