mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
refactor: changement de la philosophie de logging
This commit is contained in:
@ -6,6 +6,7 @@ const withNextIntl = createNextIntlPlugin();
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
|
reactStrictMode: true,
|
||||||
experimental: {
|
experimental: {
|
||||||
instrumentationHook: true,
|
instrumentationHook: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import Tab from '@/components/Tab';
|
|||||||
import TabContent from '@/components/TabContent';
|
import TabContent from '@/components/TabContent';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import InputText from '@/components/InputText';
|
import InputText from '@/components/InputText';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const [activeTab, setActiveTab] = useState('structure');
|
const [activeTab, setActiveTab] = useState('structure');
|
||||||
@ -54,17 +55,17 @@ export default function SettingsPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Logique pour mettre à jour l'email et le mot de passe
|
// Logique pour mettre à jour l'email et le mot de passe
|
||||||
console.log('Email:', email);
|
logger.debug('Email:', email);
|
||||||
console.log('Password:', password);
|
logger.debug('Password:', password);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSmtpSubmit = (e) => {
|
const handleSmtpSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Logique pour mettre à jour les paramètres SMTP
|
// Logique pour mettre à jour les paramètres SMTP
|
||||||
console.log('SMTP Server:', smtpServer);
|
logger.debug('SMTP Server:', smtpServer);
|
||||||
console.log('SMTP Port:', smtpPort);
|
logger.debug('SMTP Port:', smtpPort);
|
||||||
console.log('SMTP User:', smtpUser);
|
logger.debug('SMTP User:', smtpUser);
|
||||||
console.log('SMTP Password:', smtpPassword);
|
logger.debug('SMTP Password:', smtpPassword);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -23,9 +23,8 @@ import { createDatas,
|
|||||||
fetchTuitionPaymentModes } from '@/app/actions/schoolAction';
|
fetchTuitionPaymentModes } from '@/app/actions/schoolAction';
|
||||||
import SidebarTabs from '@/components/SidebarTabs';
|
import SidebarTabs from '@/components/SidebarTabs';
|
||||||
import FilesManagement from '@/components/Structure/Files/FilesManagement';
|
import FilesManagement from '@/components/Structure/Files/FilesManagement';
|
||||||
|
|
||||||
import { fetchRegisterFormFileTemplate } from '@/app/actions/subscriptionAction';
|
import { fetchRegisterFormFileTemplate } from '@/app/actions/subscriptionAction';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
@ -75,7 +74,7 @@ export default function Page() {
|
|||||||
.then((data)=> {
|
.then((data)=> {
|
||||||
setFichiers(data)
|
setFichiers(data)
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching files:', error));
|
.catch(error => logger.error('Error fetching files:', error));
|
||||||
|
|
||||||
// Fetch data for registration payment plans
|
// Fetch data for registration payment plans
|
||||||
handleRegistrationPaymentPlans();
|
handleRegistrationPaymentPlans();
|
||||||
@ -95,7 +94,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setSpecialities(data);
|
setSpecialities(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching specialities:', error));
|
.catch(error => logger.error('Error fetching specialities:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTeachers = () => {
|
const handleTeachers = () => {
|
||||||
@ -103,7 +102,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setTeachers(data);
|
setTeachers(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching teachers:', error));
|
.catch(error => logger.error('Error fetching teachers:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClasses = () => {
|
const handleClasses = () => {
|
||||||
@ -111,7 +110,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setClasses(data);
|
setClasses(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching classes:', error));
|
.catch(error => logger.error('Error fetching classes:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSchedules = () => {
|
const handleSchedules = () => {
|
||||||
@ -119,7 +118,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setSchedules(data);
|
setSchedules(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching schedules:', error));
|
.catch(error => logger.error('Error fetching schedules:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRegistrationDiscounts = () => {
|
const handleRegistrationDiscounts = () => {
|
||||||
@ -127,7 +126,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setRegistrationDiscounts(data);
|
setRegistrationDiscounts(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching registration discounts:', error));
|
.catch(error => logger.error('Error fetching registration discounts:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTuitionDiscounts = () => {
|
const handleTuitionDiscounts = () => {
|
||||||
@ -135,7 +134,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setTuitionDiscounts(data);
|
setTuitionDiscounts(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching tuition discounts:', error));
|
.catch(error => logger.error('Error fetching tuition discounts:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRegistrationFees = () => {
|
const handleRegistrationFees = () => {
|
||||||
@ -143,7 +142,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setRegistrationFees(data);
|
setRegistrationFees(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching registration fees:', error));
|
.catch(error => logger.error('Error fetching registration fees:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTuitionFees = () => {
|
const handleTuitionFees = () => {
|
||||||
@ -151,7 +150,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setTuitionFees(data);
|
setTuitionFees(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching tuition fees', error));
|
.catch(error => logger.error('Error fetching tuition fees', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRegistrationPaymentPlans = () => {
|
const handleRegistrationPaymentPlans = () => {
|
||||||
@ -159,7 +158,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setRegistrationPaymentPlans(data);
|
setRegistrationPaymentPlans(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching registration payment plans:', error));
|
.catch(error => logger.error('Error fetching registration payment plans:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTuitionPaymentPlans = () => {
|
const handleTuitionPaymentPlans = () => {
|
||||||
@ -167,7 +166,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setTuitionPaymentPlans(data);
|
setTuitionPaymentPlans(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching tuition payment plans:', error));
|
.catch(error => logger.error('Error fetching tuition payment plans:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRegistrationPaymentModes = () => {
|
const handleRegistrationPaymentModes = () => {
|
||||||
@ -175,7 +174,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setRegistrationPaymentModes(data);
|
setRegistrationPaymentModes(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching registration payment modes:', error));
|
.catch(error => logger.error('Error fetching registration payment modes:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTuitionPaymentModes = () => {
|
const handleTuitionPaymentModes = () => {
|
||||||
@ -183,7 +182,7 @@ export default function Page() {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setTuitionPaymentModes(data);
|
setTuitionPaymentModes(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching tuition payment modes:', error));
|
.catch(error => logger.error('Error fetching tuition payment modes:', error));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreate = (url, newData, setDatas) => {
|
const handleCreate = (url, newData, setDatas) => {
|
||||||
@ -193,7 +192,7 @@ export default function Page() {
|
|||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error creating data:', error);
|
logger.error('Error creating data:', error);
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -205,7 +204,7 @@ export default function Page() {
|
|||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error editing data:', error);
|
logger.error('Error editing data:', error);
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -217,7 +216,7 @@ export default function Page() {
|
|||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error deleting data:', error);
|
logger.error('Error deleting data:', error);
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -234,11 +233,11 @@ export default function Page() {
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Planning mis à jour avec succès :', data);
|
logger.debug('Planning mis à jour avec succès :', data);
|
||||||
//setDatas(data);
|
//setDatas(data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Erreur :', error);
|
logger.error('Erreur :', error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useSearchParams, useRouter } from 'next/navigation';
|
import { useSearchParams, useRouter } from 'next/navigation';
|
||||||
import InscriptionFormShared from '@/components/Inscription/InscriptionFormShared';
|
import InscriptionFormShared from '@/components/Inscription/InscriptionFormShared';
|
||||||
import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
|
import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
|
||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { mockStudent } from '@/data/mockStudent';
|
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
||||||
import { editRegisterForm, fetchRegisterForm } from '@/app/actions/subscriptionAction';
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
@ -23,20 +22,20 @@ export default function Page() {
|
|||||||
|
|
||||||
const handleSubmit = (data) => {
|
const handleSubmit = (data) => {
|
||||||
if (useFakeData) {
|
if (useFakeData) {
|
||||||
console.log('Fake submit:', data);
|
logger.debug('Fake submit:', data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
editRegisterForm(studentId, data, csrfToken)
|
editRegisterForm(studentId, data, csrfToken)
|
||||||
|
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log('Success:', result);
|
logger.debug('Success:', result);
|
||||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setFormErrors(error.details);
|
setFormErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -45,6 +45,7 @@ import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
|||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { fetchRegistrationFileGroups } from '@/app/actions/registerFileGroupAction';
|
import { fetchRegistrationFileGroups } from '@/app/actions/registerFileGroupAction';
|
||||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ export default function Page({ params: { locale } }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const requestErrorHandler = (err)=>{
|
const requestErrorHandler = (err)=>{
|
||||||
console.error('Error fetching data:', err);
|
logger.error('Error fetching data:', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,28 +160,25 @@ const registerFormArchivedDataHandler = (data) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: revoir le système de pagination et de UseEffect
|
useEffect(() => {
|
||||||
|
const fetchInitialData = async () => {
|
||||||
|
try {
|
||||||
|
const [classesData, studentsData] = await Promise.all([
|
||||||
|
fetchClasses(),
|
||||||
|
fetchStudents()
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
setClasses(classesData);
|
||||||
fetchClasses()
|
setEleves(studentsData);
|
||||||
.then(data => {
|
logger.debug('Success - Classes:', classesData);
|
||||||
setClasses(data);
|
logger.debug('Success - Students:', studentsData);
|
||||||
console.log('Success Classes:', data);
|
} catch (error) {
|
||||||
})
|
logger.error('Error fetching initial data:', error);
|
||||||
.catch(error => {
|
}
|
||||||
console.error('Error fetching classes:', error);
|
};
|
||||||
});
|
|
||||||
fetchStudents()
|
fetchInitialData();
|
||||||
.then(data => {
|
}, []);
|
||||||
console.log('Success STUDENTS:', data);
|
|
||||||
setEleves(data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
error = error.message;
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
}, [registrationFormsDataPending]);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -199,11 +197,11 @@ const registerFormArchivedDataHandler = (data) => {
|
|||||||
.catch(requestErrorHandler)
|
.catch(requestErrorHandler)
|
||||||
fetchRegisterFormFileTemplate()
|
fetchRegisterFormFileTemplate()
|
||||||
.then((data)=> {
|
.then((data)=> {
|
||||||
console.log(data);
|
logger.debug(data);
|
||||||
|
|
||||||
setFichiers(data)
|
setFichiers(data)
|
||||||
})
|
})
|
||||||
.catch((err)=>{ err = err.message; console.log(err);})
|
.catch((err)=>{ err = err.message; logger.debug(err);})
|
||||||
fetchRegistrationDiscounts()
|
fetchRegistrationDiscounts()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
setRegistrationDiscounts(data);
|
setRegistrationDiscounts(data);
|
||||||
@ -228,7 +226,7 @@ const registerFormArchivedDataHandler = (data) => {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
setGroups(data);
|
setGroups(data);
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching file groups:', error));
|
.catch(error => logger.error('Error fetching file groups:', error));
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setRegistrationFormsDataPending(mockFicheInscription);
|
setRegistrationFormsDataPending(mockFicheInscription);
|
||||||
@ -258,7 +256,7 @@ useEffect(() => {
|
|||||||
.catch(requestErrorHandler)
|
.catch(requestErrorHandler)
|
||||||
fetchRegisterFormFileTemplate()
|
fetchRegisterFormFileTemplate()
|
||||||
.then((data)=> {setFichiers(data)})
|
.then((data)=> {setFichiers(data)})
|
||||||
.catch((err)=>{ err = err.message; console.log(err);});
|
.catch((err)=>{ err = err.message; logger.debug(err);});
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setRegistrationFormsDataPending(mockFicheInscription);
|
setRegistrationFormsDataPending(mockFicheInscription);
|
||||||
@ -300,13 +298,13 @@ useEffect(()=>{
|
|||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
archiveRegisterForm(id)
|
archiveRegisterForm(id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setRegistrationForms(registrationForms.filter(fiche => fiche.id !== id));
|
setRegistrationForms(registrationForms.filter(fiche => fiche.id !== id));
|
||||||
setReloadFetch(true);
|
setReloadFetch(true);
|
||||||
alert("Le dossier d'inscription a été correctement archivé");
|
alert("Le dossier d'inscription a été correctement archivé");
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
alert("Erreur lors de l'archivage du dossier d'inscription.\nContactez l'administrateur.");
|
alert("Erreur lors de l'archivage du dossier d'inscription.\nContactez l'administrateur.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -319,11 +317,11 @@ useEffect(()=>{
|
|||||||
message: `Avertissement ! \nVous êtes sur le point d'envoyer un dossier d'inscription à ${nom} ${prenom}\nÊtes-vous sûr(e) de vouloir poursuivre l'opération ?`,
|
message: `Avertissement ! \nVous êtes sur le point d'envoyer un dossier d'inscription à ${nom} ${prenom}\nÊtes-vous sûr(e) de vouloir poursuivre l'opération ?`,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
sendRegisterForm(id).then(data => {
|
sendRegisterForm(id).then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setReloadFetch(true);
|
setReloadFetch(true);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -332,16 +330,16 @@ useEffect(()=>{
|
|||||||
const affectationClassFormSubmitHandler = (formdata)=> {
|
const affectationClassFormSubmitHandler = (formdata)=> {
|
||||||
editRegisterForm(student.id,formData, csrfToken)
|
editRegisterForm(student.id,formData, csrfToken)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setReloadFetch(true);
|
setReloadFetch(true);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error :', error);
|
logger.error('Error :', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateStatusAction = (id, newStatus) => {
|
const updateStatusAction = (id, newStatus) => {
|
||||||
console.log('Edit fiche inscription with id:', id);
|
logger.debug('Edit fiche inscription with id:', id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchChange = (event) => {
|
const handleSearchChange = (event) => {
|
||||||
@ -353,7 +351,7 @@ useEffect(()=>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createRF = (updatedData) => {
|
const createRF = (updatedData) => {
|
||||||
console.log('createRF updatedData:', updatedData);
|
logger.debug('createRF updatedData:', updatedData);
|
||||||
const selectedRegistrationFeesIds = updatedData.selectedRegistrationFees.map(feeId => feeId)
|
const selectedRegistrationFeesIds = updatedData.selectedRegistrationFees.map(feeId => feeId)
|
||||||
const selectedRegistrationDiscountsIds = updatedData.selectedRegistrationDiscounts.map(discountId => discountId)
|
const selectedRegistrationDiscountsIds = updatedData.selectedRegistrationDiscounts.map(discountId => discountId)
|
||||||
const selectedTuitionFeesIds = updatedData.selectedTuitionFees.map(feeId => feeId)
|
const selectedTuitionFeesIds = updatedData.selectedTuitionFees.map(feeId => feeId)
|
||||||
@ -389,7 +387,7 @@ useEffect(()=>{
|
|||||||
setReloadFetch(true);
|
setReloadFetch(true);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error);
|
logger.error('Error:', error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const data = {
|
const data = {
|
||||||
@ -428,17 +426,17 @@ useEffect(()=>{
|
|||||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||||
}
|
}
|
||||||
closeModal();
|
closeModal();
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
// Forcer le rechargement complet des données
|
// Forcer le rechargement complet des données
|
||||||
setReloadFetch(true);
|
setReloadFetch(true);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error);
|
logger.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error:', error);
|
logger.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { useSearchParams, useRouter } from 'next/navigation';
|
|||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { FE_PARENTS_HOME_URL} from '@/utils/Url';
|
import { FE_PARENTS_HOME_URL} from '@/utils/Url';
|
||||||
import { editRegisterForm} from '@/app/actions/subscriptionAction';
|
import { editRegisterForm} from '@/app/actions/subscriptionAction';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@ -16,10 +17,10 @@ export default function Page() {
|
|||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
try {
|
try {
|
||||||
const result = await editRegisterForm(studentId, data, csrfToken);
|
const result = await editRegisterForm(studentId, data, csrfToken);
|
||||||
console.log('Success:', result);
|
logger.debug('Success:', result);
|
||||||
router.push(FE_PARENTS_HOME_URL);
|
router.push(FE_PARENTS_HOME_URL);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
logger.error('Error:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { fetchMessages } from '@/app/actions/messagerieAction';
|
|||||||
import ProtectedRoute from '@/components/ProtectedRoute';
|
import ProtectedRoute from '@/components/ProtectedRoute';
|
||||||
import { disconnect } from '@/app/actions/authAction';
|
import { disconnect } from '@/app/actions/authAction';
|
||||||
import Popup from '@/components/Popup';
|
import Popup from '@/components/Popup';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
@ -39,10 +40,10 @@ export default function Layout({
|
|||||||
if (data) {
|
if (data) {
|
||||||
setMessages(data);
|
setMessages(data);
|
||||||
}
|
}
|
||||||
console.log('Success :', data);
|
logger.debug('Success :', data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import StatusLabel from '@/components/StatusLabel';
|
|||||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||||
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
||||||
import { fetchChildren } from '@/app/actions/subscriptionAction';
|
import { fetchChildren } from '@/app/actions/subscriptionAction';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function ParentHomePage() {
|
export default function ParentHomePage() {
|
||||||
const [actions, setActions] = useState([]);
|
const [actions, setActions] = useState([]);
|
||||||
@ -25,7 +26,7 @@ export default function ParentHomePage() {
|
|||||||
|
|
||||||
function handleEdit(eleveId) {
|
function handleEdit(eleveId) {
|
||||||
// Logique pour éditer le dossier de l'élève
|
// Logique pour éditer le dossier de l'élève
|
||||||
console.log(`Edit dossier for student id: ${eleveId}`);
|
logger.debug(`Edit dossier for student id: ${eleveId}`);
|
||||||
router.push(`${FE_PARENTS_EDIT_INSCRIPTION_URL}?id=${userId}&studentId=${eleveId}`);
|
router.push(`${FE_PARENTS_EDIT_INSCRIPTION_URL}?id=${userId}&studentId=${eleveId}`);
|
||||||
}
|
}
|
||||||
const actionColumns = [
|
const actionColumns = [
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import InputText from '@/components/InputText';
|
import InputText from '@/components/InputText';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
@ -27,8 +28,8 @@ export default function SettingsPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Logique pour mettre à jour l'email et le mot de passe
|
// Logique pour mettre à jour l'email et le mot de passe
|
||||||
console.log('Email:', email);
|
logger.debug('Email:', email);
|
||||||
console.log('Password:', password);
|
logger.debug('Password:', password);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -9,14 +9,14 @@ import Button from '@/components/Button'; // Importez le composant Button
|
|||||||
import { User, KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
import { User, KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||||
import {
|
import {
|
||||||
FE_USERS_NEW_PASSWORD_URL,
|
FE_USERS_NEW_PASSWORD_URL,
|
||||||
BE_AUTH_INFO_SESSION,
|
|
||||||
FE_ADMIN_SUBSCRIPTIONS_URL,
|
FE_ADMIN_SUBSCRIPTIONS_URL,
|
||||||
FE_PARENTS_HOME_URL
|
FE_PARENTS_HOME_URL
|
||||||
} from '@/utils/Url';
|
} from '@/utils/Url';
|
||||||
import { login } from '@/app/actions/authAction';
|
import { login } from '@/app/actions/authAction';
|
||||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||||
import { signIn, getSession } from 'next-auth/react';
|
import { getSession } from 'next-auth/react';
|
||||||
import { useCsrfToken } from '@/context/CsrfContext'; // Importez le hook useCsrfToken
|
import { useCsrfToken } from '@/context/CsrfContext'; // Importez le hook useCsrfToken
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export default function Page() {
|
|||||||
email: formData.get('login'),
|
email: formData.get('login'),
|
||||||
password: formData.get('password'),
|
password: formData.get('password'),
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
console.log('Sign In Result', result);
|
logger.debug('Sign In Result', result);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
setErrorMessage(result.error);
|
setErrorMessage(result.error);
|
||||||
@ -54,7 +54,7 @@ export default function Page() {
|
|||||||
throw new Error('Session not found');
|
throw new Error('Session not found');
|
||||||
}
|
}
|
||||||
const user = session.user;
|
const user = session.user;
|
||||||
console.log('User Session:', user);
|
logger.debug('User Session:', user);
|
||||||
localStorage.setItem('userId', user.id); // Stocker l'identifiant de l'utilisateur
|
localStorage.setItem('userId', user.id); // Stocker l'identifiant de l'utilisateur
|
||||||
if (user.droit === 0) {
|
if (user.droit === 0) {
|
||||||
// Vue ECOLE
|
// Vue ECOLE
|
||||||
@ -68,13 +68,13 @@ export default function Page() {
|
|||||||
// Cas anormal
|
// Cas anormal
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('Error during session retrieval:', error);
|
logger.error('Error during session retrieval:', error);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setErrorMessage('An error occurred during session retrieval.');
|
setErrorMessage('An error occurred during session retrieval.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('Error during sign in:', error);
|
logger.error('Error during sign in:', error);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setErrorMessage('An error occurred during sign in.');
|
setErrorMessage('An error occurred during sign in.');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import { User } from 'lucide-react'; // Importez directement les icônes nécess
|
|||||||
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { sendNewPassword } from '@/app/actions/authAction';
|
import { sendNewPassword } from '@/app/actions/authAction';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ export default function Page() {
|
|||||||
const data = {email: formData.get('email')}
|
const data = {email: formData.get('email')}
|
||||||
sendNewPassword(data, csrfToken)
|
sendNewPassword(data, csrfToken)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setUserFieldError("");
|
setUserFieldError("");
|
||||||
setErrorMessage("");
|
setErrorMessage("");
|
||||||
if (data.errorMessage === "") {
|
if (data.errorMessage === "") {
|
||||||
@ -55,9 +56,9 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
error = error.errorMessage;
|
error = error.errorMessage;
|
||||||
console.log(error);
|
logger.debug(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
|||||||
import { KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
import { KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { getResetPassword, resetPassword } from '@/app/actions/authAction';
|
import { getResetPassword, resetPassword } from '@/app/actions/authAction';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export default function Page() {
|
|||||||
} else {
|
} else {
|
||||||
getResetPassword(uuid)
|
getResetPassword(uuid)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
if(data.errorFields){
|
if(data.errorFields){
|
||||||
setPassword1FieldError(data.errorFields.password1)
|
setPassword1FieldError(data.errorFields.password1)
|
||||||
@ -49,7 +50,7 @@ export default function Page() {
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@ -67,7 +68,7 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
resetPassword(uuid,data,csrfToken)
|
resetPassword(uuid,data,csrfToken)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPassword1FieldError("")
|
setPassword1FieldError("")
|
||||||
setPassword2FieldError("")
|
setPassword2FieldError("")
|
||||||
setErrorMessage("")
|
setErrorMessage("")
|
||||||
@ -85,9 +86,9 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
error = error.errorMessage;
|
error = error.errorMessage;
|
||||||
console.log(error);
|
logger.debug(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
|||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { subscribe } from '@/app/actions/authAction';
|
import { subscribe } from '@/app/actions/authAction';
|
||||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@ -80,7 +81,7 @@ export default function Page() {
|
|||||||
password2: formData.get('password2'),
|
password2: formData.get('password2'),
|
||||||
}
|
}
|
||||||
subscribe(data,csrfToken).then(data => {
|
subscribe(data,csrfToken).then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setUserFieldError("")
|
setUserFieldError("")
|
||||||
setPassword1FieldError("")
|
setPassword1FieldError("")
|
||||||
setPassword2FieldError("")
|
setPassword2FieldError("")
|
||||||
@ -100,9 +101,9 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching data:', error);
|
logger.error('Error fetching data:', error);
|
||||||
error = error.errorMessage;
|
error = error.errorMessage;
|
||||||
console.log(error);
|
logger.debug(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { ChevronLeft, ChevronRight, Plus, ChevronDown } from 'lucide-react';
|
|||||||
import { format, addWeeks, addMonths, addYears, subWeeks, subMonths, subYears, getWeek, setMonth, setYear } from 'date-fns';
|
import { format, addWeeks, addMonths, addYears, subWeeks, subMonths, subYears, getWeek, setMonth, setYear } from 'date-fns';
|
||||||
import { fr } from 'date-fns/locale';
|
import { fr } from 'date-fns/locale';
|
||||||
import { AnimatePresence, motion } from 'framer-motion'; // Ajouter cet import
|
import { AnimatePresence, motion } from 'framer-motion'; // Ajouter cet import
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const Calendar = ({ onDateClick, onEventClick }) => {
|
const Calendar = ({ onDateClick, onEventClick }) => {
|
||||||
const { currentDate, setCurrentDate, viewType, setViewType, events, hiddenSchedules } = usePlanning();
|
const { currentDate, setCurrentDate, viewType, setViewType, events, hiddenSchedules } = usePlanning();
|
||||||
@ -40,7 +41,7 @@ const Calendar = ({ onDateClick, onEventClick }) => {
|
|||||||
// S'assurer que le filtrage est fait au niveau parent
|
// S'assurer que le filtrage est fait au niveau parent
|
||||||
const filtered = events.filter(event => !hiddenSchedules.includes(event.scheduleId));
|
const filtered = events.filter(event => !hiddenSchedules.includes(event.scheduleId));
|
||||||
setVisibleEvents(filtered);
|
setVisibleEvents(filtered);
|
||||||
console.log('Events filtrés:', filtered); // Debug
|
logger.debug('Events filtrés:', filtered); // Debug
|
||||||
}, [events, hiddenSchedules]);
|
}, [events, hiddenSchedules]);
|
||||||
|
|
||||||
const navigateDate = (direction) => {
|
const navigateDate = (direction) => {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import FeesSection from '@/components/Structure/Tarification/FeesSection';
|
|||||||
import DiscountsSection from '@/components/Structure/Tarification/DiscountsSection';
|
import DiscountsSection from '@/components/Structure/Tarification/DiscountsSection';
|
||||||
import SectionTitle from '@/components/SectionTitle';
|
import SectionTitle from '@/components/SectionTitle';
|
||||||
import ProgressStep from '@/components/ProgressStep';
|
import ProgressStep from '@/components/ProgressStep';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, registrationFees, tuitionFees, onSubmit, currentStep, groups }) => {
|
const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, registrationFees, tuitionFees, onSubmit, currentStep, groups }) => {
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@ -128,7 +129,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
console.log('Submitting form data:', formData);
|
logger.debug('Submitting form data:', formData);
|
||||||
onSubmit(formData);
|
onSubmit(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { BASE_URL } from '@/utils/Url';
|
|||||||
import DraggableFileUpload from '@/components/DraggableFileUpload';
|
import DraggableFileUpload from '@/components/DraggableFileUpload';
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import FileStatusLabel from '@/components/FileStatusLabel';
|
import FileStatusLabel from '@/components/FileStatusLabel';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
// Définition des niveaux scolaires disponibles
|
// Définition des niveaux scolaires disponibles
|
||||||
const levels = [
|
const levels = [
|
||||||
@ -69,7 +70,7 @@ export default function InscriptionFormShared({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (studentId) {
|
if (studentId) {
|
||||||
fetchRegisterForm(studentId).then((data) => {
|
fetchRegisterForm(studentId).then((data) => {
|
||||||
console.log(data);
|
logger.debug(data);
|
||||||
|
|
||||||
setFormData({
|
setFormData({
|
||||||
id: data?.student?.id || '',
|
id: data?.student?.id || '',
|
||||||
@ -108,7 +109,7 @@ export default function InscriptionFormShared({
|
|||||||
// Gestion du téléversement de fichiers
|
// Gestion du téléversement de fichiers
|
||||||
const handleFileUpload = async (file, fileName) => {
|
const handleFileUpload = async (file, fileName) => {
|
||||||
if (!file || !currentTemplateId || !formData.id) {
|
if (!file || !currentTemplateId || !formData.id) {
|
||||||
console.error('Missing required data for upload');
|
logger.error('Missing required data for upload');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ export default function InscriptionFormShared({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error uploading file:', error);
|
logger.error('Error uploading file:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ export default function InscriptionFormShared({
|
|||||||
await deleteRegisterFormFile(fileToDelete.id, csrfToken);
|
await deleteRegisterFormFile(fileToDelete.id, csrfToken);
|
||||||
setUploadedFiles(prev => prev.filter(f => parseInt(f.template) !== templateId));
|
setUploadedFiles(prev => prev.filter(f => parseInt(f.template) !== templateId));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting file:', error);
|
logger.error('Error deleting file:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import LevelLabel from '@/components/CustomLabels/LevelLabel';
|
|||||||
import { DndProvider, useDrop } from 'react-dnd';
|
import { DndProvider, useDrop } from 'react-dnd';
|
||||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const ItemTypes = {
|
const ItemTypes = {
|
||||||
TEACHER: 'teacher',
|
TEACHER: 'teacher',
|
||||||
@ -179,9 +180,9 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -201,9 +202,9 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -388,13 +389,13 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
|||||||
setRemovePopupOnConfirm(() => () => {
|
setRemovePopupOnConfirm(() => () => {
|
||||||
handleDelete(classe.id)
|
handleDelete(classe.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPopupMessage("La classe " + classe.atmosphere_name + " a été correctement supprimée");
|
setPopupMessage("La classe " + classe.atmosphere_name + " a été correctement supprimée");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
setPopupMessage("Erreur lors de la suppression de la classe " + classe.atmosphere_name);
|
setPopupMessage("Erreur lors de la suppression de la classe " + classe.atmosphere_name);
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import InputTextWithColorIcon from '@/components/InputTextWithColorIcon';
|
|||||||
import { DndProvider } from 'react-dnd';
|
import { DndProvider } from 'react-dnd';
|
||||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||||
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, handleEdit, handleDelete }) => {
|
const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, handleEdit, handleDelete }) => {
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
|||||||
setSpecialities(prevSpecialities => prevSpecialities.filter(speciality => speciality.id !== id));
|
setSpecialities(prevSpecialities => prevSpecialities.filter(speciality => speciality.id !== id));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,9 +50,9 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -71,9 +72,9 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -171,13 +172,13 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
|||||||
setRemovePopupOnConfirm(() => () => {
|
setRemovePopupOnConfirm(() => () => {
|
||||||
handleRemoveSpeciality(speciality.id)
|
handleRemoveSpeciality(speciality.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPopupMessage("La spécialité " + speciality.name + " a été correctement supprimée");
|
setPopupMessage("La spécialité " + speciality.name + " a été correctement supprimée");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
setPopupMessage("Erreur lors de la suppression de la spécialité " + speciality.name);
|
setPopupMessage("Erreur lors de la suppression de la spécialité " + speciality.name);
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
|||||||
import InputText from '@/components/InputText';
|
import InputText from '@/components/InputText';
|
||||||
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
||||||
import TeacherItem from './TeacherItem';
|
import TeacherItem from './TeacherItem';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const ItemTypes = {
|
const ItemTypes = {
|
||||||
SPECIALITY: 'speciality',
|
SPECIALITY: 'speciality',
|
||||||
@ -118,7 +119,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
setTeachers(prevTeachers => prevTeachers.filter(teacher => teacher.id !== id));
|
setTeachers(prevTeachers => prevTeachers.filter(teacher => teacher.id !== id));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
};
|
};
|
||||||
createProfile(data, csrfToken)
|
createProfile(data, csrfToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log('Success:', response);
|
logger.debug('Success:', response);
|
||||||
if (response.id) {
|
if (response.id) {
|
||||||
let idProfil = response.id;
|
let idProfil = response.id;
|
||||||
newTeacher.associated_profile = idProfil;
|
newTeacher.associated_profile = idProfil;
|
||||||
@ -144,9 +145,9 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -154,9 +155,9 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -175,7 +176,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
};
|
};
|
||||||
updateProfile(updatedData.associated_profile, data, csrfToken)
|
updateProfile(updatedData.associated_profile, data, csrfToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log('Success:', response);
|
logger.debug('Success:', response);
|
||||||
handleEdit(id, updatedData)
|
handleEdit(id, updatedData)
|
||||||
.then((updatedTeacher) => {
|
.then((updatedTeacher) => {
|
||||||
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
|
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
|
||||||
@ -183,17 +184,17 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
setFormData({});
|
setFormData({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -371,13 +372,13 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
setRemovePopupOnConfirm(() => () => {
|
setRemovePopupOnConfirm(() => () => {
|
||||||
handleRemoveTeacher(teacher.id)
|
handleRemoveTeacher(teacher.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPopupMessage("L'enseignant " + teacher.last_name + " " + teacher.first_name + " a été correctement supprimé");
|
setPopupMessage("L'enseignant " + teacher.last_name + " " + teacher.first_name + " a été correctement supprimé");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
setPopupMessage("Erreur lors de la suppression de l'enseignant " + teacher.last_name + " " + teacher.first_name);
|
setPopupMessage("Erreur lors de la suppression de l'enseignant " + teacher.last_name + " " + teacher.first_name);
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
|
|||||||
@ -9,8 +9,7 @@ import {
|
|||||||
fetchRegisterFormFileTemplate,
|
fetchRegisterFormFileTemplate,
|
||||||
createRegistrationFormFileTemplate,
|
createRegistrationFormFileTemplate,
|
||||||
editRegistrationFormFileTemplate,
|
editRegistrationFormFileTemplate,
|
||||||
deleteRegisterFormFileTemplate,
|
deleteRegisterFormFileTemplate
|
||||||
getRegisterFormFileTemplate
|
|
||||||
} from '@/app/actions/subscriptionAction';
|
} from '@/app/actions/subscriptionAction';
|
||||||
import {
|
import {
|
||||||
fetchRegistrationFileGroups,
|
fetchRegistrationFileGroups,
|
||||||
@ -19,6 +18,7 @@ import {
|
|||||||
editRegistrationFileGroup
|
editRegistrationFileGroup
|
||||||
} from '@/app/actions/registerFileGroupAction';
|
} from '@/app/actions/registerFileGroupAction';
|
||||||
import RegistrationFileGroupForm from '@/components/RegistrationFileGroupForm';
|
import RegistrationFileGroupForm from '@/components/RegistrationFileGroupForm';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
export default function FilesManagement({ csrfToken }) {
|
export default function FilesManagement({ csrfToken }) {
|
||||||
const [fichiers, setFichiers] = useState([]);
|
const [fichiers, setFichiers] = useState([]);
|
||||||
@ -55,7 +55,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
const transformedFiles = filesData.map(file => transformFileData(file, groupsData));
|
const transformedFiles = filesData.map(file => transformFileData(file, groupsData));
|
||||||
setFichiers(transformedFiles);
|
setFichiers(transformedFiles);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err.message);
|
logger.debug(err.message);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error deleting file:', error);
|
logger.error('Error deleting file:', error);
|
||||||
alert('Erreur lors de la suppression du fichier.');
|
alert('Erreur lors de la suppression du fichier.');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -113,7 +113,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error editing file:', error);
|
logger.error('Error editing file:', error);
|
||||||
alert('Erreur lors de la modification du fichier');
|
alert('Erreur lors de la modification du fichier');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -125,7 +125,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
setIsModalOpen(false);
|
setIsModalOpen(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error uploading file:', error);
|
logger.error('Error uploading file:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -142,7 +142,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
}
|
}
|
||||||
setIsGroupModalOpen(false);
|
setIsGroupModalOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error handling group:', error);
|
logger.error('Error handling group:', error);
|
||||||
alert('Erreur lors de l\'opération sur le groupe');
|
alert('Erreur lors de l\'opération sur le groupe');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -173,7 +173,7 @@ export default function FilesManagement({ csrfToken }) {
|
|||||||
alert('Groupe supprimé avec succès.');
|
alert('Groupe supprimé avec succès.');
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error deleting group:', error);
|
logger.error('Error deleting group:', error);
|
||||||
alert(error.message || 'Erreur lors de la suppression du groupe. Vérifiez qu\'aucune inscription n\'utilise ce groupe.');
|
alert(error.message || 'Erreur lors de la suppression du groupe. Vérifiez qu\'aucune inscription n\'utilise ce groupe.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { History, Clock, Users } from 'lucide-react';
|
import { History, Clock, Users } from 'lucide-react';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const ClassesList = ({ classes, onClassSelect, selectedClassId }) => {
|
const ClassesList = ({ classes, onClassSelect, selectedClassId }) => {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
@ -7,7 +8,7 @@ const ClassesList = ({ classes, onClassSelect, selectedClassId }) => {
|
|||||||
const currentSchoolYearStart = currentMonth >= 8 ? currentYear : currentYear - 1;
|
const currentSchoolYearStart = currentMonth >= 8 ? currentYear : currentYear - 1;
|
||||||
|
|
||||||
const handleClassClick = (classe) => {
|
const handleClassClick = (classe) => {
|
||||||
console.log(`Classe sélectionnée: ${classe.atmosphere_name}, Année scolaire: ${classe.school_year}`);
|
logger.debug(`Classe sélectionnée: ${classe.atmosphere_name}, Année scolaire: ${classe.school_year}`);
|
||||||
onClassSelect(classe);
|
onClassSelect(classe);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { useClasses } from '@/context/ClassesContext';
|
|||||||
import { ClasseFormProvider } from '@/context/ClasseFormContext';
|
import { ClasseFormProvider } from '@/context/ClasseFormContext';
|
||||||
import TabsStructure from '@/components/Structure/Configuration/TabsStructure';
|
import TabsStructure from '@/components/Structure/Configuration/TabsStructure';
|
||||||
import { Bookmark, Users, BookOpen, Newspaper } from 'lucide-react';
|
import { Bookmark, Users, BookOpen, Newspaper } from 'lucide-react';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
@ -88,7 +89,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
|||||||
// Utiliser `handleUpdatePlanning` pour mettre à jour le planning du niveau de la classe
|
// Utiliser `handleUpdatePlanning` pour mettre à jour le planning du niveau de la classe
|
||||||
const planningId = selectedClass.plannings_read.find(planning => planning.niveau === selectedLevel)?.planning.id;
|
const planningId = selectedClass.plannings_read.find(planning => planning.niveau === selectedLevel)?.planning.id;
|
||||||
if (planningId) {
|
if (planningId) {
|
||||||
console.log('newSchedule : ', newSchedule)
|
logger.debug('newSchedule : ', newSchedule)
|
||||||
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, newSchedule);
|
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, newSchedule);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { useClasses } from '@/context/ClassesContext';
|
|||||||
import { useClasseForm } from '@/context/ClasseFormContext';
|
import { useClasseForm } from '@/context/ClasseFormContext';
|
||||||
import { BE_SCHOOL_PLANNINGS_URL } from '@/utils/Url';
|
import { BE_SCHOOL_PLANNINGS_URL } from '@/utils/Url';
|
||||||
import { BookOpen, Users } from 'lucide-react';
|
import { BookOpen, Users } from 'lucide-react';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, handleUpdatePlanning, classe }) => {
|
const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, handleUpdatePlanning, classe }) => {
|
||||||
const { formData, setFormData } = useClasseForm();
|
const { formData, setFormData } = useClasseForm();
|
||||||
@ -33,7 +34,7 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
console.log('debug : ', selectedCell);
|
logger.debug('debug : ', selectedCell);
|
||||||
if (existingEvent) {
|
if (existingEvent) {
|
||||||
// Mode édition
|
// Mode édition
|
||||||
setEventData(existingEvent);
|
setEventData(existingEvent);
|
||||||
@ -112,7 +113,7 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
|||||||
|
|
||||||
// Appeler handleUpdatePlanning avec les arguments appropriés
|
// Appeler handleUpdatePlanning avec les arguments appropriés
|
||||||
const planningId = updatedPlanning ? updatedPlanning.planning.id : null;
|
const planningId = updatedPlanning ? updatedPlanning.planning.id : null;
|
||||||
console.log("id : ", planningId)
|
logger.debug("id : ", planningId)
|
||||||
if (planningId) {
|
if (planningId) {
|
||||||
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, updatedPlanning.emploiDuTemps);
|
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, updatedPlanning.emploiDuTemps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import Table from '@/components/Table';
|
|||||||
import Popup from '@/components/Popup';
|
import Popup from '@/components/Popup';
|
||||||
import CheckBox from '@/components/CheckBox';
|
import CheckBox from '@/components/CheckBox';
|
||||||
import InputText from '@/components/InputText';
|
import InputText from '@/components/InputText';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||||
|
|
||||||
const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, handleDelete, type, subscriptionMode = false, selectedDiscounts, handleDiscountSelection }) => {
|
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));
|
setDiscounts(prevDiscounts => prevDiscounts.filter(discount => discount.id !== id));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
|
|||||||
if (error && typeof error === 'object') {
|
if (error && typeof error === 'object') {
|
||||||
setLocalErrors(error);
|
setLocalErrors(error);
|
||||||
} else {
|
} else {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -64,7 +64,7 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
|
|||||||
if (error && typeof error === 'object') {
|
if (error && typeof error === 'object') {
|
||||||
setLocalErrors(error);
|
setLocalErrors(error);
|
||||||
} else {
|
} else {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} 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));
|
setDiscounts(prevDiscounts => prevDiscounts.map(discount => discount.id === id ? { ...discount, discount_type: updatedData.discount_type } : discount));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -217,13 +217,13 @@ const DiscountsSection = ({ discounts, setDiscounts, handleCreate, handleEdit, h
|
|||||||
setRemovePopupOnConfirm(() => () => {
|
setRemovePopupOnConfirm(() => () => {
|
||||||
handleRemoveDiscount(discount.id)
|
handleRemoveDiscount(discount.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPopupMessage("Réduction correctement supprimé");
|
setPopupMessage("Réduction correctement supprimé");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
setPopupMessage("Erreur lors de la suppression de la réduction");
|
setPopupMessage("Erreur lors de la suppression de la réduction");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import Table from '@/components/Table';
|
|||||||
import Popup from '@/components/Popup';
|
import Popup from '@/components/Popup';
|
||||||
import CheckBox from '@/components/CheckBox';
|
import CheckBox from '@/components/CheckBox';
|
||||||
import InputText from '@/components/InputText';
|
import InputText from '@/components/InputText';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
|||||||
setFees(prevFees => prevFees.filter(fee => fee.id !== id));
|
setFees(prevFees => prevFees.filter(fee => fee.id !== id));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,9 +50,9 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -72,9 +73,9 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
|||||||
setLocalErrors({});
|
setLocalErrors({});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
console.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setLocalErrors(error.details);
|
setLocalErrors(error.details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -98,7 +99,7 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
|||||||
setFees(prevFees => prevFees.map(fee => fee.id === id ? { ...fee, is_active: !isActive } : fee));
|
setFees(prevFees => prevFees.map(fee => fee.id === id ? { ...fee, is_active: !isActive } : fee));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -206,13 +207,13 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
|||||||
setRemovePopupOnConfirm(() => () => {
|
setRemovePopupOnConfirm(() => () => {
|
||||||
handleRemoveFee(fee.id)
|
handleRemoveFee(fee.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data);
|
logger.debug('Success:', data);
|
||||||
setPopupMessage(labelTypeFrais + " correctement supprimé");
|
setPopupMessage(labelTypeFrais + " correctement supprimé");
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error archiving data:', error);
|
logger.error('Error archiving data:', error);
|
||||||
setPopupMessage("Erreur lors de la suppression du " + labelTypeFrais);
|
setPopupMessage("Erreur lors de la suppression du " + labelTypeFrais);
|
||||||
setPopupVisible(true);
|
setPopupVisible(true);
|
||||||
setRemovePopupVisible(false);
|
setRemovePopupVisible(false);
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
import React, { createContext, useContext, useState, useEffect } from 'react';
|
import React, { createContext, useContext, useState, useEffect } from 'react';
|
||||||
import { BE_AUTH_CSRF_URL } from '@/utils/Url';
|
import { BE_AUTH_CSRF_URL } from '@/utils/Url';
|
||||||
import { setCsrfToken } from '@/utils/getCsrfToken';
|
import { setCsrfToken } from '@/utils/getCsrfToken';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const CsrfContext = createContext();
|
const CsrfContext = createContext();
|
||||||
|
|
||||||
@ -23,11 +24,11 @@ export const CsrfProvider = ({ children }) => {
|
|||||||
if (data && data.csrfToken) {
|
if (data && data.csrfToken) {
|
||||||
setCsrfTokenState(data.csrfToken);
|
setCsrfTokenState(data.csrfToken);
|
||||||
setCsrfToken(data.csrfToken); // Définir le token CSRF global
|
setCsrfToken(data.csrfToken); // Définir le token CSRF global
|
||||||
console.log('CSRF Token reçu:', data.csrfToken);
|
logger.debug('CSRF Token reçu:', data.csrfToken);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching CSRF token:', error);
|
logger.error('Error fetching CSRF token:', error);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import NextAuth from 'next-auth';
|
|||||||
import CredentialsProvider from 'next-auth/providers/credentials';
|
import CredentialsProvider from 'next-auth/providers/credentials';
|
||||||
import { getJWT, refreshJWT } from '@/app/actions/authAction';
|
import { getJWT, refreshJWT } from '@/app/actions/authAction';
|
||||||
import jwt_decode from 'jsonwebtoken';
|
import jwt_decode from 'jsonwebtoken';
|
||||||
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
secret: process.env.AUTH_SECRET,
|
secret: process.env.AUTH_SECRET,
|
||||||
@ -22,7 +23,7 @@ const options = {
|
|||||||
const user = await getJWT(data);
|
const user = await getJWT(data);
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
console.log("API response:", user);
|
logger.debug("API response:", user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ const options = {
|
|||||||
throw new Error('Failed to refresh token');
|
throw new Error('Failed to refresh token');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Refresh token failed:", error);
|
logger.error("Refresh token failed:", error);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
39
Front-End/src/utils/logger.js
Normal file
39
Front-End/src/utils/logger.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
const getCallerInfo = () => {
|
||||||
|
const stackLine = new Error().stack?.split('\n')[3].trim();
|
||||||
|
// Regex pour extraire le fichier, la ligne et la colonne
|
||||||
|
const match = stackLine.match(/\(?([^)]+):(\d+):(\d+)\)?$/);
|
||||||
|
|
||||||
|
let callerInfo = '(unknown)';
|
||||||
|
if (match) {
|
||||||
|
const [ , filePath, line, column ] = match;
|
||||||
|
const fileName = filePath.split('/').pop(); // Garde juste le nom du fichier
|
||||||
|
callerInfo = `[${fileName}:${line}]`;
|
||||||
|
}
|
||||||
|
return callerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
const logger = {
|
||||||
|
debug: (...args) => {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
console.log.apply(console, ['[DEBUG]',`${getCallerInfo()}`, ...args])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (...args) => {
|
||||||
|
// Les erreurs sont toujours loguées
|
||||||
|
|
||||||
|
console.error.apply(console,['[ERROR]',`${getCallerInfo()}`,...args]);
|
||||||
|
},
|
||||||
|
warn: (...args) => {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
console.warn.apply(console, ['[WARN]',`${getCallerInfo()}`, ...args]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
info: (...args) => {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
console.info.apply(console, ['[INFO]',`${getCallerInfo()}`, ...args]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default logger;
|
||||||
Reference in New Issue
Block a user