fix: Unicité des fees + utilisation de l'establishmentID [#44]

This commit is contained in:
N3WT DE COMPET
2025-05-01 14:46:17 +02:00
parent 24069b894e
commit d37e6c384d
5 changed files with 25 additions and 15 deletions

View File

@ -6,8 +6,7 @@ import CheckBox from '@/components/CheckBox';
import InputText from '@/components/InputText';
import logger from '@/utils/logger';
import SectionHeader from '@/components/SectionHeader';
import { ESTABLISHMENT_ID } from '@/utils/Url';
import { useEstablishment } from '@/context/EstablishmentContext';
const FeesSection = ({
fees,
@ -33,6 +32,7 @@ const FeesSection = ({
const labelTypeFrais =
type === 0 ? "Frais d'inscription" : 'Frais de scolarité';
const { selectedEstablishmentId } = useEstablishment();
// Récupération des messages d'erreur
const getError = (field) => {
return localErrors?.[field]?.[0];
@ -48,7 +48,7 @@ const FeesSection = ({
validity_end_date: '',
discounts: [],
type: type,
establishment: ESTABLISHMENT_ID,
establishment: selectedEstablishmentId,
});
};
@ -64,7 +64,12 @@ const FeesSection = ({
const handleSaveNewFee = () => {
if (newFee.name && newFee.base_amount) {
handleCreate(newFee)
const feeData = {
...newFee,
establishment: selectedEstablishmentId,
};
handleCreate(feeData)
.then((createdFee) => {
setFees([createdFee, ...fees]);
setNewFee(null);