mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +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} */
|
||||
const nextConfig = {
|
||||
output: "standalone",
|
||||
reactStrictMode: true,
|
||||
experimental: {
|
||||
instrumentationHook: true,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import Tab from '@/components/Tab';
|
||||
import TabContent from '@/components/TabContent';
|
||||
import Button from '@/components/Button';
|
||||
import InputText from '@/components/InputText';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [activeTab, setActiveTab] = useState('structure');
|
||||
@ -54,17 +55,17 @@ export default function SettingsPage() {
|
||||
return;
|
||||
}
|
||||
// Logique pour mettre à jour l'email et le mot de passe
|
||||
console.log('Email:', email);
|
||||
console.log('Password:', password);
|
||||
logger.debug('Email:', email);
|
||||
logger.debug('Password:', password);
|
||||
};
|
||||
|
||||
const handleSmtpSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
// Logique pour mettre à jour les paramètres SMTP
|
||||
console.log('SMTP Server:', smtpServer);
|
||||
console.log('SMTP Port:', smtpPort);
|
||||
console.log('SMTP User:', smtpUser);
|
||||
console.log('SMTP Password:', smtpPassword);
|
||||
logger.debug('SMTP Server:', smtpServer);
|
||||
logger.debug('SMTP Port:', smtpPort);
|
||||
logger.debug('SMTP User:', smtpUser);
|
||||
logger.debug('SMTP Password:', smtpPassword);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -23,9 +23,8 @@ import { createDatas,
|
||||
fetchTuitionPaymentModes } from '@/app/actions/schoolAction';
|
||||
import SidebarTabs from '@/components/SidebarTabs';
|
||||
import FilesManagement from '@/components/Structure/Files/FilesManagement';
|
||||
|
||||
import { fetchRegisterFormFileTemplate } from '@/app/actions/subscriptionAction';
|
||||
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
|
||||
export default function Page() {
|
||||
@ -75,7 +74,7 @@ export default function Page() {
|
||||
.then((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
|
||||
handleRegistrationPaymentPlans();
|
||||
@ -95,7 +94,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setSpecialities(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching specialities:', error));
|
||||
.catch(error => logger.error('Error fetching specialities:', error));
|
||||
};
|
||||
|
||||
const handleTeachers = () => {
|
||||
@ -103,7 +102,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setTeachers(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching teachers:', error));
|
||||
.catch(error => logger.error('Error fetching teachers:', error));
|
||||
};
|
||||
|
||||
const handleClasses = () => {
|
||||
@ -111,7 +110,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setClasses(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching classes:', error));
|
||||
.catch(error => logger.error('Error fetching classes:', error));
|
||||
};
|
||||
|
||||
const handleSchedules = () => {
|
||||
@ -119,7 +118,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setSchedules(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching schedules:', error));
|
||||
.catch(error => logger.error('Error fetching schedules:', error));
|
||||
};
|
||||
|
||||
const handleRegistrationDiscounts = () => {
|
||||
@ -127,7 +126,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setRegistrationDiscounts(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching registration discounts:', error));
|
||||
.catch(error => logger.error('Error fetching registration discounts:', error));
|
||||
};
|
||||
|
||||
const handleTuitionDiscounts = () => {
|
||||
@ -135,7 +134,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setTuitionDiscounts(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching tuition discounts:', error));
|
||||
.catch(error => logger.error('Error fetching tuition discounts:', error));
|
||||
};
|
||||
|
||||
const handleRegistrationFees = () => {
|
||||
@ -143,7 +142,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setRegistrationFees(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching registration fees:', error));
|
||||
.catch(error => logger.error('Error fetching registration fees:', error));
|
||||
};
|
||||
|
||||
const handleTuitionFees = () => {
|
||||
@ -151,7 +150,7 @@ export default function Page() {
|
||||
.then(data => {
|
||||
setTuitionFees(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching tuition fees', error));
|
||||
.catch(error => logger.error('Error fetching tuition fees', error));
|
||||
};
|
||||
|
||||
const handleRegistrationPaymentPlans = () => {
|
||||
@ -159,7 +158,7 @@ export default function Page() {
|
||||
.then(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 = () => {
|
||||
@ -167,7 +166,7 @@ export default function Page() {
|
||||
.then(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 = () => {
|
||||
@ -175,7 +174,7 @@ export default function Page() {
|
||||
.then(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 = () => {
|
||||
@ -183,7 +182,7 @@ export default function Page() {
|
||||
.then(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) => {
|
||||
@ -193,7 +192,7 @@ export default function Page() {
|
||||
return data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error creating data:', error);
|
||||
logger.error('Error creating data:', error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
@ -205,7 +204,7 @@ export default function Page() {
|
||||
return data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error editing data:', error);
|
||||
logger.error('Error editing data:', error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
@ -217,7 +216,7 @@ export default function Page() {
|
||||
return data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error deleting data:', error);
|
||||
logger.error('Error deleting data:', error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
@ -234,11 +233,11 @@ export default function Page() {
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Planning mis à jour avec succès :', data);
|
||||
logger.debug('Planning mis à jour avec succès :', data);
|
||||
//setDatas(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur :', error);
|
||||
logger.error('Erreur :', error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
'use client'
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import InscriptionFormShared from '@/components/Inscription/InscriptionFormShared';
|
||||
import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { mockStudent } from '@/data/mockStudent';
|
||||
import { editRegisterForm, fetchRegisterForm } from '@/app/actions/subscriptionAction';
|
||||
|
||||
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
export default function Page() {
|
||||
@ -23,20 +22,20 @@ export default function Page() {
|
||||
|
||||
const handleSubmit = (data) => {
|
||||
if (useFakeData) {
|
||||
console.log('Fake submit:', data);
|
||||
logger.debug('Fake submit:', data);
|
||||
return;
|
||||
}
|
||||
|
||||
editRegisterForm(studentId, data, csrfToken)
|
||||
|
||||
.then((result) => {
|
||||
console.log('Success:', result);
|
||||
logger.debug('Success:', result);
|
||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setFormErrors(error.details);
|
||||
}
|
||||
});
|
||||
|
||||
@ -45,6 +45,7 @@ import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { fetchRegistrationFileGroups } from '@/app/actions/registerFileGroupAction';
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -99,7 +100,7 @@ export default function Page({ params: { locale } }) {
|
||||
}
|
||||
|
||||
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(() => {
|
||||
fetchClasses()
|
||||
.then(data => {
|
||||
setClasses(data);
|
||||
console.log('Success Classes:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching classes:', error);
|
||||
});
|
||||
useEffect(() => {
|
||||
const fetchInitialData = async () => {
|
||||
try {
|
||||
const [classesData, studentsData] = await Promise.all([
|
||||
fetchClasses(),
|
||||
fetchStudents()
|
||||
.then(data => {
|
||||
console.log('Success STUDENTS:', data);
|
||||
setEleves(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
error = error.message;
|
||||
console.log(error);
|
||||
});
|
||||
}, [registrationFormsDataPending]);
|
||||
]);
|
||||
|
||||
setClasses(classesData);
|
||||
setEleves(studentsData);
|
||||
logger.debug('Success - Classes:', classesData);
|
||||
logger.debug('Success - Students:', studentsData);
|
||||
} catch (error) {
|
||||
logger.error('Error fetching initial data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchInitialData();
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@ -199,11 +197,11 @@ const registerFormArchivedDataHandler = (data) => {
|
||||
.catch(requestErrorHandler)
|
||||
fetchRegisterFormFileTemplate()
|
||||
.then((data)=> {
|
||||
console.log(data);
|
||||
logger.debug(data);
|
||||
|
||||
setFichiers(data)
|
||||
})
|
||||
.catch((err)=>{ err = err.message; console.log(err);})
|
||||
.catch((err)=>{ err = err.message; logger.debug(err);})
|
||||
fetchRegistrationDiscounts()
|
||||
.then(data => {
|
||||
setRegistrationDiscounts(data);
|
||||
@ -228,7 +226,7 @@ const registerFormArchivedDataHandler = (data) => {
|
||||
.then(data => {
|
||||
setGroups(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching file groups:', error));
|
||||
.catch(error => logger.error('Error fetching file groups:', error));
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
setRegistrationFormsDataPending(mockFicheInscription);
|
||||
@ -258,7 +256,7 @@ useEffect(() => {
|
||||
.catch(requestErrorHandler)
|
||||
fetchRegisterFormFileTemplate()
|
||||
.then((data)=> {setFichiers(data)})
|
||||
.catch((err)=>{ err = err.message; console.log(err);});
|
||||
.catch((err)=>{ err = err.message; logger.debug(err);});
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
setRegistrationFormsDataPending(mockFicheInscription);
|
||||
@ -300,13 +298,13 @@ useEffect(()=>{
|
||||
onConfirm: () => {
|
||||
archiveRegisterForm(id)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setRegistrationForms(registrationForms.filter(fiche => fiche.id !== id));
|
||||
setReloadFetch(true);
|
||||
alert("Le dossier d'inscription a été correctement archivé");
|
||||
})
|
||||
.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.");
|
||||
});
|
||||
}
|
||||
@ -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 ?`,
|
||||
onConfirm: () => {
|
||||
sendRegisterForm(id).then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
logger.error('Error fetching data:', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -332,16 +330,16 @@ useEffect(()=>{
|
||||
const affectationClassFormSubmitHandler = (formdata)=> {
|
||||
editRegisterForm(student.id,formData, csrfToken)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error :', error);
|
||||
logger.error('Error :', error);
|
||||
});
|
||||
}
|
||||
|
||||
const updateStatusAction = (id, newStatus) => {
|
||||
console.log('Edit fiche inscription with id:', id);
|
||||
logger.debug('Edit fiche inscription with id:', id);
|
||||
};
|
||||
|
||||
const handleSearchChange = (event) => {
|
||||
@ -353,7 +351,7 @@ useEffect(()=>{
|
||||
};
|
||||
|
||||
const createRF = (updatedData) => {
|
||||
console.log('createRF updatedData:', updatedData);
|
||||
logger.debug('createRF updatedData:', updatedData);
|
||||
const selectedRegistrationFeesIds = updatedData.selectedRegistrationFees.map(feeId => feeId)
|
||||
const selectedRegistrationDiscountsIds = updatedData.selectedRegistrationDiscounts.map(discountId => discountId)
|
||||
const selectedTuitionFeesIds = updatedData.selectedTuitionFees.map(feeId => feeId)
|
||||
@ -389,7 +387,7 @@ useEffect(()=>{
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
logger.error('Error:', error);
|
||||
});
|
||||
} else {
|
||||
const data = {
|
||||
@ -428,17 +426,17 @@ useEffect(()=>{
|
||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||
}
|
||||
closeModal();
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
// Forcer le rechargement complet des données
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
logger.error('Error:', 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 { FE_PARENTS_HOME_URL} from '@/utils/Url';
|
||||
import { editRegisterForm} from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function Page() {
|
||||
const searchParams = useSearchParams();
|
||||
@ -16,10 +17,10 @@ export default function Page() {
|
||||
const handleSubmit = async (data) => {
|
||||
try {
|
||||
const result = await editRegisterForm(studentId, data, csrfToken);
|
||||
console.log('Success:', result);
|
||||
logger.debug('Success:', result);
|
||||
router.push(FE_PARENTS_HOME_URL);
|
||||
} 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 { disconnect } from '@/app/actions/authAction';
|
||||
import Popup from '@/components/Popup';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
@ -39,10 +40,10 @@ export default function Layout({
|
||||
if (data) {
|
||||
setMessages(data);
|
||||
}
|
||||
console.log('Success :', data);
|
||||
logger.debug('Success :', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
logger.error('Error fetching data:', error);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false);
|
||||
|
||||
@ -7,6 +7,7 @@ import StatusLabel from '@/components/StatusLabel';
|
||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
||||
import { fetchChildren } from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function ParentHomePage() {
|
||||
const [actions, setActions] = useState([]);
|
||||
@ -25,7 +26,7 @@ export default function ParentHomePage() {
|
||||
|
||||
function handleEdit(eleveId) {
|
||||
// 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}`);
|
||||
}
|
||||
const actionColumns = [
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import Button from '@/components/Button';
|
||||
import InputText from '@/components/InputText';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [email, setEmail] = useState('');
|
||||
@ -27,8 +28,8 @@ export default function SettingsPage() {
|
||||
return;
|
||||
}
|
||||
// Logique pour mettre à jour l'email et le mot de passe
|
||||
console.log('Email:', email);
|
||||
console.log('Password:', password);
|
||||
logger.debug('Email:', email);
|
||||
logger.debug('Password:', password);
|
||||
};
|
||||
|
||||
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 {
|
||||
FE_USERS_NEW_PASSWORD_URL,
|
||||
BE_AUTH_INFO_SESSION,
|
||||
FE_ADMIN_SUBSCRIPTIONS_URL,
|
||||
FE_PARENTS_HOME_URL
|
||||
} from '@/utils/Url';
|
||||
import { login } from '@/app/actions/authAction';
|
||||
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 logger from '@/utils/logger';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -44,7 +44,7 @@ export default function Page() {
|
||||
email: formData.get('login'),
|
||||
password: formData.get('password'),
|
||||
}).then(result => {
|
||||
console.log('Sign In Result', result);
|
||||
logger.debug('Sign In Result', result);
|
||||
setIsLoading(false);
|
||||
if (result.error) {
|
||||
setErrorMessage(result.error);
|
||||
@ -54,7 +54,7 @@ export default function Page() {
|
||||
throw new Error('Session not found');
|
||||
}
|
||||
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
|
||||
if (user.droit === 0) {
|
||||
// Vue ECOLE
|
||||
@ -68,13 +68,13 @@ export default function Page() {
|
||||
// Cas anormal
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error during session retrieval:', error);
|
||||
logger.error('Error during session retrieval:', error);
|
||||
setIsLoading(false);
|
||||
setErrorMessage('An error occurred during session retrieval.');
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error during sign in:', error);
|
||||
logger.error('Error during sign in:', error);
|
||||
setIsLoading(false);
|
||||
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 { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { sendNewPassword } from '@/app/actions/authAction';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -38,7 +39,7 @@ export default function Page() {
|
||||
const data = {email: formData.get('email')}
|
||||
sendNewPassword(data, csrfToken)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setUserFieldError("");
|
||||
setErrorMessage("");
|
||||
if (data.errorMessage === "") {
|
||||
@ -55,9 +56,9 @@ export default function Page() {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
logger.error('Error fetching data:', error);
|
||||
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 { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { getResetPassword, resetPassword } from '@/app/actions/authAction';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -37,7 +38,7 @@ export default function Page() {
|
||||
} else {
|
||||
getResetPassword(uuid)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setIsLoading(true);
|
||||
if(data.errorFields){
|
||||
setPassword1FieldError(data.errorFields.password1)
|
||||
@ -49,7 +50,7 @@ export default function Page() {
|
||||
setIsLoading(false);
|
||||
})
|
||||
.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)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setPassword1FieldError("")
|
||||
setPassword2FieldError("")
|
||||
setErrorMessage("")
|
||||
@ -85,9 +86,9 @@ export default function Page() {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
logger.error('Error fetching data:', error);
|
||||
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 { subscribe } from '@/app/actions/authAction';
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function Page() {
|
||||
const searchParams = useSearchParams();
|
||||
@ -80,7 +81,7 @@ export default function Page() {
|
||||
password2: formData.get('password2'),
|
||||
}
|
||||
subscribe(data,csrfToken).then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setUserFieldError("")
|
||||
setPassword1FieldError("")
|
||||
setPassword2FieldError("")
|
||||
@ -100,9 +101,9 @@ export default function Page() {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
logger.error('Error fetching data:', error);
|
||||
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 { fr } from 'date-fns/locale';
|
||||
import { AnimatePresence, motion } from 'framer-motion'; // Ajouter cet import
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const Calendar = ({ onDateClick, onEventClick }) => {
|
||||
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
|
||||
const filtered = events.filter(event => !hiddenSchedules.includes(event.scheduleId));
|
||||
setVisibleEvents(filtered);
|
||||
console.log('Events filtrés:', filtered); // Debug
|
||||
logger.debug('Events filtrés:', filtered); // Debug
|
||||
}, [events, hiddenSchedules]);
|
||||
|
||||
const navigateDate = (direction) => {
|
||||
|
||||
@ -8,6 +8,7 @@ import FeesSection from '@/components/Structure/Tarification/FeesSection';
|
||||
import DiscountsSection from '@/components/Structure/Tarification/DiscountsSection';
|
||||
import SectionTitle from '@/components/SectionTitle';
|
||||
import ProgressStep from '@/components/ProgressStep';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, registrationFees, tuitionFees, onSubmit, currentStep, groups }) => {
|
||||
const [formData, setFormData] = useState({
|
||||
@ -128,7 +129,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
console.log('Submitting form data:', formData);
|
||||
logger.debug('Submitting form data:', formData);
|
||||
onSubmit(formData);
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import { BASE_URL } from '@/utils/Url';
|
||||
import DraggableFileUpload from '@/components/DraggableFileUpload';
|
||||
import Modal from '@/components/Modal';
|
||||
import FileStatusLabel from '@/components/FileStatusLabel';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
// Définition des niveaux scolaires disponibles
|
||||
const levels = [
|
||||
@ -69,7 +70,7 @@ export default function InscriptionFormShared({
|
||||
useEffect(() => {
|
||||
if (studentId) {
|
||||
fetchRegisterForm(studentId).then((data) => {
|
||||
console.log(data);
|
||||
logger.debug(data);
|
||||
|
||||
setFormData({
|
||||
id: data?.student?.id || '',
|
||||
@ -108,7 +109,7 @@ export default function InscriptionFormShared({
|
||||
// Gestion du téléversement de fichiers
|
||||
const handleFileUpload = async (file, fileName) => {
|
||||
if (!file || !currentTemplateId || !formData.id) {
|
||||
console.error('Missing required data for upload');
|
||||
logger.error('Missing required data for upload');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ export default function InscriptionFormShared({
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
setUploadedFiles(prev => prev.filter(f => parseInt(f.template) !== templateId));
|
||||
} 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 { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const ItemTypes = {
|
||||
TEACHER: 'teacher',
|
||||
@ -179,9 +180,9 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -201,9 +202,9 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -388,13 +389,13 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
||||
setRemovePopupOnConfirm(() => () => {
|
||||
handleDelete(classe.id)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setPopupMessage("La classe " + classe.atmosphere_name + " a été correctement supprimée");
|
||||
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 classe " + classe.atmosphere_name);
|
||||
setPopupVisible(true);
|
||||
setRemovePopupVisible(false);
|
||||
|
||||
@ -6,6 +6,7 @@ import InputTextWithColorIcon from '@/components/InputTextWithColorIcon';
|
||||
import { DndProvider } from 'react-dnd';
|
||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
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));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -49,9 +50,9 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -71,9 +72,9 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -171,13 +172,13 @@ const SpecialitiesSection = ({ specialities, setSpecialities, handleCreate, hand
|
||||
setRemovePopupOnConfirm(() => () => {
|
||||
handleRemoveSpeciality(speciality.id)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setPopupMessage("La spécialité " + speciality.name + " a été correctement supprimée");
|
||||
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 spécialité " + speciality.name);
|
||||
setPopupVisible(true);
|
||||
setRemovePopupVisible(false);
|
||||
|
||||
@ -10,6 +10,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import InputText from '@/components/InputText';
|
||||
import SpecialityItem from '@/components/Structure/Configuration/SpecialityItem';
|
||||
import TeacherItem from './TeacherItem';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const ItemTypes = {
|
||||
SPECIALITY: 'speciality',
|
||||
@ -118,7 +119,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
setTeachers(prevTeachers => prevTeachers.filter(teacher => teacher.id !== id));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -133,7 +134,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
};
|
||||
createProfile(data, csrfToken)
|
||||
.then(response => {
|
||||
console.log('Success:', response);
|
||||
logger.debug('Success:', response);
|
||||
if (response.id) {
|
||||
let idProfil = response.id;
|
||||
newTeacher.associated_profile = idProfil;
|
||||
@ -144,9 +145,9 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -154,9 +155,9 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -175,7 +176,7 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
};
|
||||
updateProfile(updatedData.associated_profile, data, csrfToken)
|
||||
.then(response => {
|
||||
console.log('Success:', response);
|
||||
logger.debug('Success:', response);
|
||||
handleEdit(id, updatedData)
|
||||
.then((updatedTeacher) => {
|
||||
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
|
||||
@ -183,17 +184,17 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
setFormData({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -371,13 +372,13 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
||||
setRemovePopupOnConfirm(() => () => {
|
||||
handleRemoveTeacher(teacher.id)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setPopupMessage("L'enseignant " + teacher.last_name + " " + teacher.first_name + " a été 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 l'enseignant " + teacher.last_name + " " + teacher.first_name);
|
||||
setPopupVisible(true);
|
||||
setRemovePopupVisible(false);
|
||||
|
||||
@ -9,8 +9,7 @@ import {
|
||||
fetchRegisterFormFileTemplate,
|
||||
createRegistrationFormFileTemplate,
|
||||
editRegistrationFormFileTemplate,
|
||||
deleteRegisterFormFileTemplate,
|
||||
getRegisterFormFileTemplate
|
||||
deleteRegisterFormFileTemplate
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
import {
|
||||
fetchRegistrationFileGroups,
|
||||
@ -19,6 +18,7 @@ import {
|
||||
editRegistrationFileGroup
|
||||
} from '@/app/actions/registerFileGroupAction';
|
||||
import RegistrationFileGroupForm from '@/components/RegistrationFileGroupForm';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function FilesManagement({ csrfToken }) {
|
||||
const [fichiers, setFichiers] = useState([]);
|
||||
@ -55,7 +55,7 @@ export default function FilesManagement({ csrfToken }) {
|
||||
const transformedFiles = filesData.map(file => transformFileData(file, groupsData));
|
||||
setFichiers(transformedFiles);
|
||||
}).catch(err => {
|
||||
console.log(err.message);
|
||||
logger.debug(err.message);
|
||||
});
|
||||
}, []);
|
||||
|
||||
@ -70,7 +70,7 @@ export default function FilesManagement({ csrfToken }) {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error deleting file:', error);
|
||||
logger.error('Error deleting file:', error);
|
||||
alert('Erreur lors de la suppression du fichier.');
|
||||
});
|
||||
};
|
||||
@ -113,7 +113,7 @@ export default function FilesManagement({ csrfToken }) {
|
||||
setIsEditing(false);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error editing file:', error);
|
||||
logger.error('Error editing file:', error);
|
||||
alert('Erreur lors de la modification du fichier');
|
||||
});
|
||||
} else {
|
||||
@ -125,7 +125,7 @@ export default function FilesManagement({ csrfToken }) {
|
||||
setIsModalOpen(false);
|
||||
})
|
||||
.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);
|
||||
} catch (error) {
|
||||
console.error('Error handling group:', error);
|
||||
logger.error('Error handling group:', error);
|
||||
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.');
|
||||
})
|
||||
.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.');
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { History, Clock, Users } from 'lucide-react';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const ClassesList = ({ classes, onClassSelect, selectedClassId }) => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
@ -7,7 +8,7 @@ const ClassesList = ({ classes, onClassSelect, selectedClassId }) => {
|
||||
const currentSchoolYearStart = currentMonth >= 8 ? currentYear : currentYear - 1;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import { useClasses } from '@/context/ClassesContext';
|
||||
import { ClasseFormProvider } from '@/context/ClasseFormContext';
|
||||
import TabsStructure from '@/components/Structure/Configuration/TabsStructure';
|
||||
import { Bookmark, Users, BookOpen, Newspaper } from 'lucide-react';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
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
|
||||
const planningId = selectedClass.plannings_read.find(planning => planning.niveau === selectedLevel)?.planning.id;
|
||||
if (planningId) {
|
||||
console.log('newSchedule : ', newSchedule)
|
||||
logger.debug('newSchedule : ', newSchedule)
|
||||
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, newSchedule);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,6 +4,7 @@ import { useClasses } from '@/context/ClassesContext';
|
||||
import { useClasseForm } from '@/context/ClasseFormContext';
|
||||
import { BE_SCHOOL_PLANNINGS_URL } from '@/utils/Url';
|
||||
import { BookOpen, Users } from 'lucide-react';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, handleUpdatePlanning, classe }) => {
|
||||
const { formData, setFormData } = useClasseForm();
|
||||
@ -33,7 +34,7 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
console.log('debug : ', selectedCell);
|
||||
logger.debug('debug : ', selectedCell);
|
||||
if (existingEvent) {
|
||||
// Mode édition
|
||||
setEventData(existingEvent);
|
||||
@ -112,7 +113,7 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
||||
|
||||
// Appeler handleUpdatePlanning avec les arguments appropriés
|
||||
const planningId = updatedPlanning ? updatedPlanning.planning.id : null;
|
||||
console.log("id : ", planningId)
|
||||
logger.debug("id : ", planningId)
|
||||
if (planningId) {
|
||||
handleUpdatePlanning(BE_SCHOOL_PLANNINGS_URL, planningId, updatedPlanning.emploiDuTemps);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -4,6 +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';
|
||||
|
||||
@ -34,7 +35,7 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
||||
setFees(prevFees => prevFees.filter(fee => fee.id !== id));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -49,9 +50,9 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', error.details);
|
||||
setLocalErrors(error.details);
|
||||
}
|
||||
});
|
||||
@ -72,9 +73,9 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
||||
setLocalErrors({});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error.message);
|
||||
logger.error('Error:', error.message);
|
||||
if (error.details) {
|
||||
console.error('Form errors:', error.details);
|
||||
logger.error('Form errors:', 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));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -206,13 +207,13 @@ const FeesSection = ({ fees, setFees, discounts, handleCreate, handleEdit, handl
|
||||
setRemovePopupOnConfirm(() => () => {
|
||||
handleRemoveFee(fee.id)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
logger.debug('Success:', data);
|
||||
setPopupMessage(labelTypeFrais + " 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 du " + labelTypeFrais);
|
||||
setPopupVisible(true);
|
||||
setRemovePopupVisible(false);
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import React, { createContext, useContext, useState, useEffect } from 'react';
|
||||
import { BE_AUTH_CSRF_URL } from '@/utils/Url';
|
||||
import { setCsrfToken } from '@/utils/getCsrfToken';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const CsrfContext = createContext();
|
||||
|
||||
@ -23,11 +24,11 @@ export const CsrfProvider = ({ children }) => {
|
||||
if (data && data.csrfToken) {
|
||||
setCsrfTokenState(data.csrfToken);
|
||||
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 => {
|
||||
console.error('Error fetching CSRF token:', error);
|
||||
logger.error('Error fetching CSRF token:', error);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false);
|
||||
|
||||
@ -2,6 +2,7 @@ import NextAuth from 'next-auth';
|
||||
import CredentialsProvider from 'next-auth/providers/credentials';
|
||||
import { getJWT, refreshJWT } from '@/app/actions/authAction';
|
||||
import jwt_decode from 'jsonwebtoken';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
const options = {
|
||||
secret: process.env.AUTH_SECRET,
|
||||
@ -22,7 +23,7 @@ const options = {
|
||||
const user = await getJWT(data);
|
||||
|
||||
if (user) {
|
||||
console.log("API response:", user);
|
||||
logger.debug("API response:", user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ const options = {
|
||||
throw new Error('Failed to refresh token');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Refresh token failed:", error);
|
||||
logger.error("Refresh token failed:", error);
|
||||
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