emptymycart

This commit is contained in:
DavidBelisle
2022-11-23 15:41:49 -05:00
parent 6120bf544a
commit a33c04b71f
2 changed files with 20 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ import { Row, Col, Button } from "react-bootstrap";
import { useNavigate } from "react-router-dom";
import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content";
import CartProvider from "../components/Cart";
import { CartContext } from "../components/Cart";
const ReviewInvoice = () => {
@@ -14,9 +14,9 @@ const ReviewInvoice = () => {
const navigate = useNavigate();
const mySwal = withReactContent(Swal);
const cart = useContext(CartProvider);
const cart = useContext(CartContext);
//const [products, setProducts] = useState([]);
const [products, setProducts] = useState([]);
const [thisInvoice, setThisInvoice] = useState({
firstName: "",
@@ -55,7 +55,7 @@ const ReviewInvoice = () => {
}
})
//var prods = [];
// var prods = [];
// Object.keys(thisInvoice.prodQuant).map((k) => {
// fetch(`https://localhost:7292/api/Product?id=${k}`)
// .then(async (response) => {
@@ -135,9 +135,12 @@ const ReviewInvoice = () => {
title: 'Commande envoyée avec succès!',
timer: 2000,
icon: "success"
})
cart.items = [];
navigate('./Morceaux');
}).then(
() => {
cart.emptyCart();
navigate('/morceaux');
}
)
}
else {
console.log("Erreur de creation la commande #" + thisInvoice.id);