afficher le x que lorsque la commande est confirmé ou en préparation et fix de la page Invoice d'admin

This commit is contained in:
Victor Turgeon 2022-11-25 12:19:02 -05:00
parent 565f677c38
commit a7f343545f
3 changed files with 12 additions and 11 deletions

View File

@ -105,8 +105,9 @@ const InvoiceItem = ({ invoice, onCancel }) => {
<div className="invoice-item-products"> <div className="invoice-item-products">
<div className="invoice-product-delete"> <div className="invoice-product-delete">
<h4 className='simple-item-title' >Produits</h4> <h4 className='simple-item-title' >Produits</h4>
{(invoice.status == 0 || invoice.status == 2 )&&
<h1 className='simple-item-buttons'><FontAwesomeIcon icon={faTimes} className='btn-effacer-morceau' style={{ color: "red", cursor: 'pointer', margin: 'auto' }} <h1 className='simple-item-buttons'><FontAwesomeIcon icon={faTimes} className='btn-effacer-morceau' style={{ color: "red", cursor: 'pointer', margin: 'auto' }}
onClick={() => onCancel(invoice.id)} /></h1> onClick={() => onCancel(invoice.id)} /></h1>}
</div> </div>
<ul className="invoice-item-product-list"> <ul className="invoice-item-product-list">
{invoice.products.map((p) => ( {invoice.products.map((p) => (

View File

@ -33,16 +33,16 @@ const Invoices = () => {
const handleCancelInvoice = async (id) => { const handleCancelInvoice = async (id) => {
mySwal.fire({ mySwal.fire({
title: `Effacer la commande?`, title: `Annuler la commande?`,
text: 'Êtes-vous certain de vouloir effacer cette commande (cette action est irréversible)?', text: 'Êtes-vous certain de vouloir annuler cette commande (cette action est irréversible)?',
icon: 'warning', icon: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonText: 'Oui', confirmButtonText: 'Oui',
cancelButtonText: 'Non', cancelButtonText: 'Non',
}).then(async (result) => { }).then(async (result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
fetch(`https://localhost:7292/api/Invoice?id=${id}`, { fetch(`https://localhost:7292/api/Invoice/Cancel/${id}`, {
method: 'CANCEL', method: 'POST',
mode: 'cors', mode: 'cors',
credentials: 'include' credentials: 'include'
}).then(async (response) => { }).then(async (response) => {
@ -50,11 +50,11 @@ const Invoices = () => {
const deletedId = await response.json(); const deletedId = await response.json();
setInvoices(invoices.filter((invoice) => invoice.id !== deletedId)); setInvoices(invoices.filter((invoice) => invoice.id !== deletedId));
onShowAlert('Suppression de la commande avec succès!', 2000); onShowAlert('Annulation de la commande avec succès!', 2000);
} }
else { else {
mySwal.fire({ mySwal.fire({
title: `Erreur lors de la suppression de la commande...`, title: `Erreur lors de l'annulation de la commande...`,
text: `L'erreur: ${response}`, text: `L'erreur: ${response}`,
icon: 'error', icon: 'error',
}); });

View File

@ -29,8 +29,8 @@ const MyInvoices = () => {
const handleCancelInvoice = async (id) => { const handleCancelInvoice = async (id) => {
mySwal.fire({ mySwal.fire({
title: `Effacer la commande?`, title: `Annuler la commande?`,
text: 'Êtes-vous certain de vouloir effacer cette commande (cette action est irréversible)?', text: 'Êtes-vous certain de vouloir annuler cette commande (cette action est irréversible)?',
icon: 'warning', icon: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonText: 'Oui', confirmButtonText: 'Oui',
@ -54,7 +54,7 @@ const MyInvoices = () => {
} }
else { else {
mySwal.fire({ mySwal.fire({
title: `Erreur lors de la suppression de la commande...`, title: `Erreur lors de l'annulation de la commande...`,
text: `L'erreur: ${await response.json()}`, text: `L'erreur: ${await response.json()}`,
icon: 'error', icon: 'error',
}); });