mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
fix: Ajout du % ou € en mode édition de réduction
This commit is contained in:
@ -86,6 +86,20 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleToggleDiscountTypeEdition = (id) => {
|
||||||
|
if (editingDiscount) {
|
||||||
|
setFormData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
discount_type: prevData.discount_type === 0 ? 1 : 0,
|
||||||
|
}));
|
||||||
|
} else if (newDiscount) {
|
||||||
|
setNewDiscount((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
discount_type: prevData.discount_type === 0 ? 1 : 0,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
if (editingDiscount) {
|
if (editingDiscount) {
|
||||||
@ -124,7 +138,19 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
|
|||||||
case 'LIBELLE':
|
case 'LIBELLE':
|
||||||
return renderInputField('name', currentData.name, handleChange, 'Libellé de la réduction');
|
return renderInputField('name', currentData.name, handleChange, 'Libellé de la réduction');
|
||||||
case 'REMISE':
|
case 'REMISE':
|
||||||
return renderInputField('amount', currentData.amount, handleChange,'Montant');
|
return (
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
{renderInputField('amount', currentData.amount, handleChange,'Montant')}
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleToggleDiscountTypeEdition(discount.id)}
|
||||||
|
className="flex justify-center items-center text-emerald-500 hover:text-emerald-700 ml-2"
|
||||||
|
>
|
||||||
|
{currentData.discount_type === 0 ? <EuroIcon className="w-5 h-5" /> : <Percent className="w-5 h-5" />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
case 'DESCRIPTION':
|
case 'DESCRIPTION':
|
||||||
return renderInputField('description', currentData.description, handleChange, 'Description');
|
return renderInputField('description', currentData.description, handleChange, 'Description');
|
||||||
case 'ACTIONS':
|
case 'ACTIONS':
|
||||||
|
|||||||
Reference in New Issue
Block a user