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