fix pour que ça update les invoices dans le ui quand on cancel
This commit is contained in:
parent
a7f343545f
commit
5d64c7d8ca
@ -24,7 +24,7 @@ const Invoices = () => {
|
|||||||
var json = await response.json();
|
var json = await response.json();
|
||||||
setInvoices(json);
|
setInvoices(json);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
console.log("Erreur lors de la requête des invoices");
|
console.log("Erreur lors de la requête des invoices");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -47,10 +47,17 @@ const Invoices = () => {
|
|||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const deletedId = await response.json();
|
const deletedInvoice = await response.json();
|
||||||
setInvoices(invoices.filter((invoice) => invoice.id !== deletedId));
|
var newInvoice = invoices.find(x => x.id == deletedInvoice.id);
|
||||||
|
console.log(newInvoice);
|
||||||
|
newInvoice.status = deletedInvoice.status;
|
||||||
|
setInvoices([...(invoices.filter(x => x.id !== newInvoice.id)), { ...newInvoice }].sort((a, b) => a.id - b.id));
|
||||||
|
|
||||||
onShowAlert('Annulation de la commande avec succès!', 2000);
|
mySwal.fire({
|
||||||
|
title: `Commande annulée...`,
|
||||||
|
text: `La commande a été annulée!`,
|
||||||
|
icon: 'success',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mySwal.fire({
|
mySwal.fire({
|
||||||
|
@ -20,7 +20,7 @@ const MyInvoices = () => {
|
|||||||
var json = await response.json();
|
var json = await response.json();
|
||||||
setInvoices(json);
|
setInvoices(json);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
console.log("Erreur lors de la requête des invoices");
|
console.log("Erreur lors de la requête des invoices");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -43,8 +43,11 @@ const MyInvoices = () => {
|
|||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const deletedId = await response.json();
|
const deletedInvoice = await response.json();
|
||||||
setInvoices(invoices.filter((invoice) => invoice.id !== deletedId));
|
var newInvoice = invoices.find(x => x.id == deletedInvoice.id);
|
||||||
|
console.log(newInvoice);
|
||||||
|
newInvoice.status = deletedInvoice.status;
|
||||||
|
setInvoices([...(invoices.filter(x => x.id !== newInvoice.id)), { ...newInvoice }].sort((a, b) => a.id - b.id));
|
||||||
|
|
||||||
mySwal.fire({
|
mySwal.fire({
|
||||||
title: `Commande annulée...`,
|
title: `Commande annulée...`,
|
||||||
|
@ -758,6 +758,7 @@ a {
|
|||||||
width: 50%;
|
width: 50%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invoice-item-products {
|
.invoice-item-products {
|
||||||
|
Loading…
Reference in New Issue
Block a user