Le paiement se rend sur stripes!

This commit is contained in:
Victor Turgeon
2022-12-08 19:40:40 -05:00
parent 41ddc7d0e3
commit 72e7193580
4 changed files with 103 additions and 81 deletions

View File

@@ -4,8 +4,6 @@ import ReviewProdList from "../components/ReviewProdList";
import TotalProductsPrice from "../components/TotalProductsPrice";
import { Row, Col, Button } from "react-bootstrap";
import { useNavigate } from "react-router-dom";
import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content";
import { CartContext } from "../components/Cart";
import StripeContainer from "../components/StripeContainer"
@@ -13,7 +11,7 @@ const ReviewInvoice = () => {
const navigate = useNavigate();
const mySwal = withReactContent(Swal);
const cart = useContext(CartContext);
@@ -90,41 +88,42 @@ const ReviewInvoice = () => {
navigate("/formulaire")
}
const handleConfirmer = async () => {
const json = JSON.stringify(thisInvoice);
const response = await fetch(`https://localhost:7292/api/Invoice`, {
method: 'POST',
credentials: 'include',
mode: 'cors',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: json
})
if (response.ok) {
mySwal.fire({
title: 'Commande envoyée avec succès!',
timer: 2000,
icon: "success"
}).then(
() => {
cart.emptyCart();
navigate('/morceaux');
}
)
}
else {
console.log("Erreur de creation la commande #" + thisInvoice.id);
mySwal.fire({
title: 'Erreur!',
timer: 2000,
icon: "error"
})
}
// const handleConfirmer = async () => {
// const json = JSON.stringify(thisInvoice);
}
// const response = await fetch(`https://localhost:7292/api/Invoice`, {
// method: 'POST',
// credentials: 'include',
// mode: 'cors',
// headers: {
// 'Accept': 'application/json',
// 'Content-Type': 'application/json'
// },
// body: json
// })
// if (response.ok) {
// mySwal.fire({
// title: 'Commande envoyée avec succès!',
// timer: 2000,
// icon: "success"
// }).then(
// () => {
// cart.emptyCart();
// navigate('/morceaux');
// }
// )
// }
// else {
// console.log("Erreur de creation la commande #" + thisInvoice.id);
// mySwal.fire({
// title: 'Erreur!',
// timer: 2000,
// icon: "error"
// })
// }
// }
return (
<>
@@ -177,21 +176,21 @@ const ReviewInvoice = () => {
<TotalProductsPrice
/>
</div>
<Row className="invoice-buttons">
{/* <Col xs={6}>
<Row className="invoice-buttons">
{/* <Col xs={6}>
<Button className="invoice-button confirmer" onClick={handleConfirmer}>Confirmer</Button>
</Col> */}
<Col xs={12}>
<Button className="invoice-button modifier" onClick={handleModify}>Modifier</Button>
</Col>
</Row>
<Col xs={12}>
<Button className="invoice-button modifier" onClick={handleModify}>Modifier</Button>
</Col>
</Row>
</Col>
<Col xs={6} md={8}>
<ReviewProdList
/>
</Col>
</Row>
<StripeContainer cost={total} />
<StripeContainer cost={total} invoice={thisInvoice} />
</>
);