refactor: changement de la philosophie de logging

This commit is contained in:
Luc SORIGNET
2025-02-22 15:28:20 +01:00
parent 508847940c
commit c7723eceee
28 changed files with 217 additions and 161 deletions

View File

@ -4,7 +4,7 @@ import Table from '@/components/Table';
import Popup from '@/components/Popup';
import CheckBox from '@/components/CheckBox';
import InputText from '@/components/InputText';
import logger from '@/utils/logger';
import { ESTABLISHMENT_ID } from '@/utils/Url';
const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, handleDelete, type, subscriptionMode = false, selectedDiscounts, handleDiscountSelection }) => {
@ -28,7 +28,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
setDiscounts(prevDiscounts => prevDiscounts.filter(discount => discount.id !== id));
})
.catch(error => {
console.error(error);
logger.error(error);
});
};
@ -44,7 +44,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
if (error && typeof error === 'object') {
setLocalErrors(error);
} else {
console.error(error);
logger.error(error);
}
});
} else {
@ -64,7 +64,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
if (error && typeof error === 'object') {
setLocalErrors(error);
} else {
console.error(error);
logger.error(error);
}
});
} else {
@ -87,7 +87,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
setDiscounts(prevDiscounts => prevDiscounts.map(discount => discount.id === id ? { ...discount, discount_type: updatedData.discount_type } : discount));
})
.catch(error => {
console.error(error);
logger.error(error);
});
};
@ -148,7 +148,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
return (
<div className="flex justify-center space-x-2">
{renderInputField('amount', currentData.amount, handleChange,'Montant')}
<button
type="button"
onClick={() => handleToggleDiscountTypeEdition(discount.id)}
@ -217,13 +217,13 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
setRemovePopupOnConfirm(() => () => {
handleRemoveDiscount(discount.id)
.then(data => {
console.log('Success:', data);
logger.debug('Success:', data);
setPopupMessage("Réduction correctement supprimé");
setPopupVisible(true);
setRemovePopupVisible(false);
})
.catch(error => {
console.error('Error archiving data:', error);
logger.error('Error archiving data:', error);
setPopupMessage("Erreur lors de la suppression de la réduction");
setPopupVisible(true);
setRemovePopupVisible(false);