CAMARCHECRISS

This commit is contained in:
DavidBelisle 2022-11-23 17:35:55 -05:00
parent e52abc3108
commit 8943d2e8b7
2 changed files with 28 additions and 32 deletions

View File

@ -116,7 +116,8 @@ public class InvoiceController : Controller {
LastName = sinv.LastName, LastName = sinv.LastName,
EmailAddress = sinv.EmailAddress, EmailAddress = sinv.EmailAddress,
PhoneNumber = sinv.PhoneNumber, PhoneNumber = sinv.PhoneNumber,
PurchaseDate = DateTime.Now PurchaseDate = DateTime.Now,
Products = new List<InvoiceModel.ProductInvoice>()
}; };
AddressModel ad; AddressModel ad;
user.Wait(); user.Wait();

View File

@ -7,17 +7,14 @@ import { useNavigate } from "react-router-dom";
import Swal from "sweetalert2"; import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content"; import withReactContent from "sweetalert2-react-content";
import { CartContext } from "../components/Cart"; import { CartContext } from "../components/Cart";
import { useRef } from "react";
const ReviewInvoice = () => { const ReviewInvoice = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const mySwal = withReactContent(Swal); const mySwal = withReactContent(Swal);
const cart = useRef(useContext(CartContext)); const cart = useContext(CartContext);
//const [products, setProducts] = useState([]);
const [thisInvoice, setThisInvoice] = useState({ const [thisInvoice, setThisInvoice] = useState({
firstName: "", firstName: "",
@ -39,14 +36,19 @@ const ReviewInvoice = () => {
const thisInvoice = cookies.get('invoice'); const thisInvoice = cookies.get('invoice');
if (thisInvoice != null) { if (thisInvoice != null) {
var dic = {}; var dic = {};
if (cart.items.length > 0) {
if (cart.current.items.length > 0) { cart.items.forEach((item) =>
cart.current.items.forEach((item) => dic[item.id] = item.quantity
dic[item.id] = item.qty
) )
} }
//dic[5] = 1; async function test() {
const json = JSON.stringify(dic);
console.log(await json);
}
test();
setThisInvoice((e) => { setThisInvoice((e) => {
return { return {
@ -69,7 +71,7 @@ const ReviewInvoice = () => {
else { else {
console.log("No invoice to review!"); console.log("No invoice to review!");
} }
}, []); }, [cart]);
// const handleAddOne = (id) => { // const handleAddOne = (id) => {
@ -114,10 +116,19 @@ const ReviewInvoice = () => {
const handleConfirmer = async () => { const handleConfirmer = async () => {
// let formData = new FormData(); // var dic = {};
// Object.keys(thisInvoice).map((k) => { // if (cart.items.length > 0) {
// formData.set(k, thisInvoice[k]); // cart.items.forEach((item) =>
// }); // dic[item.id] = item.quantity
// )
// }
// const json = JSON.stringify(dic);
// console.log(await json);
// const json1 = JSON.stringify(cart.items);
// console.log(await json1);
//setThisInvoice({ ...thisInvoice, prodQuant: dic });
const json = JSON.stringify(thisInvoice); const json = JSON.stringify(thisInvoice);
console.log(json); console.log(json);
@ -163,58 +174,46 @@ const ReviewInvoice = () => {
<div className="review-invoice-info"> <div className="review-invoice-info">
<div> <div>
<label className="bold">Prénom: </label> <label>{thisInvoice.firstName}</label> <label className="bold">Prénom: </label> <label>{thisInvoice.firstName}</label>
{/* <input value={firstName} onChange={(e) => setFirstName(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Nom: </label> <label>{thisInvoice.lastName}</label> <label className="bold">Nom: </label> <label>{thisInvoice.lastName}</label>
{/* <input value={lastName} onChange={(e) => setLastName(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Téléphone: </label> <label>{thisInvoice.phoneNumber}</label> <label className="bold">Téléphone: </label> <label>{thisInvoice.phoneNumber}</label>
{/* <input value={phoneNumber} onChange={(e) => setPhoneNumber(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Courriel: </label> <label>{thisInvoice.emailAddress}</label> <label className="bold">Courriel: </label> <label>{thisInvoice.emailAddress}</label>
{/* <input value={emailAddress} onChange={(e) => setEmailAddress(e.target.value)} /> */}
</div> </div>
</div> </div>
<div className="review-invoice-address-container"> <div className="review-invoice-address-container">
<div> <div>
<label className="bold">Numéro civique: </label> <label>{thisInvoice.civicNumber}</label> <label className="bold">Numéro civique: </label> <label>{thisInvoice.civicNumber}</label>
{/* <input type="number" min="0" value={civicNumber} onChange={(e) => setCivicNumber(e.target.value)} /> */}
</div> </div>
{thisInvoice.appartment != null ? {thisInvoice.appartment != null ?
<div> <div>
<label className="bold">Numéro d'appartement: </label> <label>{thisInvoice.appartment}</label> <label className="bold">Numéro d'appartement: </label> <label>{thisInvoice.appartment}</label>
{/* <input value={appartment} onChange={(e) => setAppartment(e.target.value)} /> */}
</div> </div>
: null : null
} }
<div> <div>
<label className="bold">Rue: </label> <label>{thisInvoice.street}</label> <label className="bold">Rue: </label> <label>{thisInvoice.street}</label>
{/* <input value={street} onChange={(e) => setStreet(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Ville: </label> <label>{thisInvoice.city}</label> <label className="bold">Ville: </label> <label>{thisInvoice.city}</label>
{/* <input value={city} onChange={(e) => setCity(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Province (abréviation): </label> <label>{thisInvoice.province}</label> <label className="bold">Province (abréviation): </label> <label>{thisInvoice.province}</label>
{/* <input value={province} onChange={(e) => setProvince(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Pays: </label> <label>{thisInvoice.country}</label> <label className="bold">Pays: </label> <label>{thisInvoice.country}</label>
{/* <input value={country} onChange={(e) => setCountry(e.target.value)} /> */}
</div> </div>
<div> <div>
<label className="bold">Code postal: </label> <label>{thisInvoice.postalCode}</label> <label className="bold">Code postal: </label> <label>{thisInvoice.postalCode}</label>
{/* <input value={postalCode} onChange={(e) => setPostalCode(e.target.value)} /> */}
</div> </div>
</div> </div>
<div className="review-invoice-info"> <div className="review-invoice-info">
<TotalProductsPrice <TotalProductsPrice
//products={cart.items}
/> />
</div> </div>
<Row className="invoice-buttons"> <Row className="invoice-buttons">
@ -228,10 +227,6 @@ const ReviewInvoice = () => {
</Col> </Col>
<Col xs={6} md={8}> <Col xs={6} md={8}>
<ReviewProdList <ReviewProdList
//products={cart.items}
//onAddOne={handleAddOne}
//onRemoveOne={handleRemoveOne}
//onRemoveProduct={handleRemoveProduct}
/> />
</Col> </Col>
</Row> </Row>