fix pour que ça update les invoices dans le ui quand on cancel
This commit is contained in:
parent
a7f343545f
commit
5d64c7d8ca
@ -47,10 +47,17 @@ const Invoices = () => {
|
||||
credentials: 'include'
|
||||
}).then(async (response) => {
|
||||
if (response.ok) {
|
||||
const deletedId = await response.json();
|
||||
setInvoices(invoices.filter((invoice) => invoice.id !== deletedId));
|
||||
const deletedInvoice = await response.json();
|
||||
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 {
|
||||
mySwal.fire({
|
||||
|
@ -43,8 +43,11 @@ const MyInvoices = () => {
|
||||
credentials: 'include'
|
||||
}).then(async (response) => {
|
||||
if (response.ok) {
|
||||
const deletedId = await response.json();
|
||||
setInvoices(invoices.filter((invoice) => invoice.id !== deletedId));
|
||||
const deletedInvoice = await response.json();
|
||||
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({
|
||||
title: `Commande annulée...`,
|
||||
|
@ -758,6 +758,7 @@ a {
|
||||
width: 50%;
|
||||
margin: auto;
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.invoice-item-products {
|
||||
|
Loading…
Reference in New Issue
Block a user