fix: application des recommandations linter es pour générer un build de prod

This commit is contained in:
Luc SORIGNET
2025-02-15 13:02:16 +01:00
parent 9716373fa2
commit d1aa8b54fb
23 changed files with 131 additions and 91 deletions

View File

@ -5,12 +5,31 @@ const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
webpack: (config, { isServer }) => {
// Configuration pour améliorer le hot reload dans Docker
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
}
return config
},
experimental: {
instrumentationHook: true,
},
env: {
NEXT_PUBLIC_APP_VERSION: pkg.version,
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'i.pravatar.cc',
port: '',
pathname: '/**',
},
],
},
};
export default withNextIntl(nextConfig);

View File

@ -26,6 +26,7 @@ import {
import { disconnect } from '@/app/lib/authAction';
import { fetchEstablishment } from '@/app/lib/schoolAction';
import Image from 'next/image';
export default function Layout({
children,
@ -75,13 +76,13 @@ export default function Layout({
<>
{!isLoading && (
<div className="flex min-h-screen bg-gray-50">
<Sidebar establishment={establishment} currentPage={currentPage} items={Object.values(sidebarItems)} className="h-full" />
<Sidebar establishment={establishment} currentPage={currentPage} items={Object.values(sidebarItems)} className="h-full" />
<div className="flex flex-col flex-1">
{/* Header - h-16 = 64px */}
<header className="h-16 bg-white border-b border-gray-200 px-8 py-4 flex items-center justify-between z-9">
<div className="text-xl font-semibold">{headerTitle}</div>
<DropdownMenu
buttonContent={<img src="https://i.pravatar.cc/32" alt="Profile" className="w-8 h-8 rounded-full cursor-pointer" />}
buttonContent={<Image src="https://i.pravatar.cc/32" alt="Profile" className="w-8 h-8 rounded-full cursor-pointer" width={150} height={150} />}
items={dropdownItems}
buttonClassName=""
menuClassName="absolute right-0 mt-2 w-48 bg-white border border-gray-200 rounded shadow-lg"

View File

@ -154,8 +154,8 @@ export default function DashboardPage() {
<div className="flex flex-wrap">
{classes.map((classe) => (
<div className="lg:col-span-2 bg-white p-6 rounded-lg shadow-sm border border-gray-100 mr-4">
<ClasseDetails key={classe.id} classe={classe} />
<div key={classe.id} className="lg:col-span-2 bg-white p-6 rounded-lg shadow-sm border border-gray-100 mr-4">
<ClasseDetails classe={classe} />
</div>
))}
</div>

View File

@ -239,7 +239,7 @@ const registerFormArchivedDataHandler = (data) => {
fetchDataAndSetState();
}, [reloadFetch, currentPage]);
}, [reloadFetch, itemsPerPage, currentPage,activeTab, searchTerm]);
useEffect(() => {
const fetchDataAndSetState = () => {
@ -271,7 +271,7 @@ const timeoutId = setTimeout(() => {
fetchDataAndSetState();
}, 500); // Debounce la recherche
return () => clearTimeout(timeoutId);
}, [searchTerm]);
}, [currentPage,itemsPerPage,searchTerm]);
/**
* UseEffect to update page count of tab
@ -284,7 +284,7 @@ useEffect(()=>{
} else if (activeTab === 'archived') {
setTotalPages(Math.ceil(totalArchives / itemsPerPage));
}
},[currentPage]);
},[currentPage,activeTab,itemsPerPage,totalPending,totalSubscribed,totalArchives]);
/**
* Archives a registration form after user confirmation.
*

View File

@ -35,7 +35,7 @@ export default function Layout({
.finally(() => {
setIsLoading(false);
});
}, [userId]);
}, [setUserId, userId]);
if (isLoading) {
return <div>Loading...</div>;

View File

@ -1,6 +1,7 @@
'use client'
import React, { useState, useRef, useEffect } from 'react';
import { SendHorizontal } from 'lucide-react';
import Image from 'next/image';
const contacts = [
{ id: 1, name: 'Facturation', profilePic: 'https://i.pravatar.cc/32' },
@ -61,7 +62,7 @@ export default function MessageriePage() {
className={`p-2 cursor-pointer ${selectedContact?.id === contact.id ? 'bg-gray-200' : ''}`}
onClick={() => setSelectedContact(contact)}
>
<img src={contact.profilePic} alt={`${contact.name}'s profile`} className="w-8 h-8 rounded-full inline-block mr-2" />
<Image src={contact.profilePic} alt={`${contact.name}'s profile`} className="w-8 h-8 rounded-full inline-block mr-2" width={150} height={150} />
{contact.name}
</div>
))}
@ -75,7 +76,7 @@ export default function MessageriePage() {
style={{ borderRadius: message.isResponse ? '20px 20px 0 20px' : '20px 20px 20px 0', minWidth: '25%' }}
>
<div className="flex items-center mb-1">
<img src={selectedContact.profilePic} alt={`${selectedContact.name}'s profile`} className="w-8 h-8 rounded-full inline-block mr-2" />
<Image src={selectedContact.profilePic} alt={`${selectedContact.name}'s profile`} className="w-8 h-8 rounded-full inline-block mr-2" width={150} height={150}/>
<span className="text-xs text-gray-600">{selectedContact.name}</span>
<span className="text-xs text-gray-400 ml-2">{new Date(message.date).toLocaleTimeString()}</span>
</div>

View File

@ -52,7 +52,7 @@ export default function Page() {
console.error('Error fetching data:', error);
});
}
}, []);
}, [uuid]);
function validate(formData) {
if (useFakeData) {

View File

@ -0,0 +1,17 @@
'use client';
import Link from 'next/link';
import Logo from '@/components/Logo';
export default function Error() {
return (
<div className='flex items-center justify-center min-h-screen bg-emerald-500'>
<div className='text-center p-6'>
<Logo className="w-32 h-32 mx-auto mb-4" />
<h2 className='text-2xl font-bold text-emerald-900 mb-4'>Une erreur est survenue</h2>
<p className='text-emerald-900 mb-4'>Désolé, une erreur s&apos;est produite.</p>
<Link className="text-gray-900 hover:underline" href="/">Retour Accueil</Link>
</div>
</div>
);
}

View File

@ -1,15 +1,17 @@
import Link from 'next/link'
import Logo from '../components/Logo'
'use client';
import Link from 'next/link';
import Logo from '@/components/Logo';
export default function NotFound() {
return (
<div className='flex items-center justify-center min-h-screen bg-emerald-500'>
<div className='text-center p-6 '>
<div className='text-center p-6'>
<Logo className="w-32 h-32 mx-auto mb-4" />
<h2 className='text-2xl font-bold text-emerald-900 mb-4'>404 | Page non trouvée</h2>
<p className='text-emerald-900 mb-4'>La ressource que vous souhaitez consulter n'existe pas ou plus.</p>
<p className='text-emerald-900 mb-4'>La ressource que vous souhaitez consulter n&apos;existe pas ou plus.</p>
<Link className="text-gray-900 hover:underline" href="/">Retour Accueil</Link>
</div>
</div>
)
);
}

View File

@ -1,6 +1,5 @@
import React from 'react';
import { NextIntlClientProvider } from 'next-intl';
import {getMessages} from 'next-intl/server';
import "@/css/tailwind.css";
@ -22,12 +21,13 @@ export const metadata = {
};
export default async function RootLayout({ children, params: { locale } }) {
const messages = await getMessages();
const messages = await getMessages(locale);
return (
<html lang={locale}>
<body>
<NextIntlClientProvider messages={messages}>
<NextIntlClientProvider messages={messages} locale={locale}>
{children}
</NextIntlClientProvider>
</body>

View File

@ -75,7 +75,7 @@ const Calendar = ({ onDateClick, onEventClick }) => {
onClick={() => setCurrentDate(new Date())}
className="px-3 py-1.5 text-sm font-medium text-gray-700 hover:text-gray-900 bg-gray-100 hover:bg-gray-200 rounded-md transition-colors"
>
Aujourd'hui
Aujourd&apos;hui
</button>
<button onClick={() => navigateDate('prev')} className="p-2 hover:bg-gray-100 rounded-full">
<ChevronLeft className="w-5 h-5" />

View File

@ -11,18 +11,20 @@ const DropdownMenu = ({ buttonContent, items, buttonClassName, menuClassName, dr
const actualSetDropdownOpen = isControlled ? propSetDropdownOpen : setDropdownOpen;
const handleClickOutside = (event) => {
if (menuRef.current && !menuRef.current.contains(event.target)) {
actualSetDropdownOpen(false);
}
};
useEffect(() => {
const handleClickOutside = (event) => {
if (menuRef.current && !menuRef.current.contains(event.target)) {
actualSetDropdownOpen(false);
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);
}, [actualSetDropdownOpen]);
return (
<div className="relative" ref={menuRef}>
<button className={buttonClassName} onClick={() => actualSetDropdownOpen(!actualDropdownOpen)}>
@ -33,7 +35,7 @@ const DropdownMenu = ({ buttonContent, items, buttonClassName, menuClassName, dr
{items.map((item, index) => (
<button
key={index}
className="block w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 flex items-center gap-2"
className="w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 flex items-center gap-2"
onClick={() => {
item.onClick();
actualSetDropdownOpen(false);

View File

@ -14,7 +14,7 @@ export default function EventModal({ isOpen, onClose, eventData, setEventData })
color: schedules[0].color
}));
}
}, [schedules, eventData.scheduleId]);
}, [schedules, eventData.scheduleId,setEventData]);
if (!isOpen) return null;

View File

@ -23,7 +23,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
selectedTuitionDiscounts: [],
selectedTuitionFees: [],
selectedFileGroup: null // Ajout du groupe de fichiers sélectionné
});
}, [registrationFees, registrationDiscounts]);
const [step, setStep] = useState(currentStep || 1);
const [selectedStudent, setSelectedEleve] = useState('');
@ -79,7 +79,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
);
setTotalRegistrationAmount(initialTotalRegistrationAmount);
}, [registrationDiscounts, registrationFees]);
}, [registrationDiscounts, registrationFees,calculateFinalRegistrationAmount]);
useEffect(() => {
setStep(currentStep || 1);
@ -176,7 +176,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
});
};
const calculateFinalRegistrationAmount = (selectedRegistrationFees, selectedRegistrationDiscounts) => {
const calculateFinalRegistrationAmount = useCallback((selectedRegistrationFees, selectedRegistrationDiscounts) => {
const totalFees = selectedRegistrationFees.reduce((sum, feeId) => {
const fee = registrationFees.find(f => f.id === feeId);
if (fee && !isNaN(parseFloat(fee.base_amount))) {
@ -200,7 +200,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
const finalAmount = totalFees - totalDiscounts;
return finalAmount.toFixed(2);
};
},[registrationDiscounts, registrationFees]);
const calculateFinalTuitionAmount = (selectedTuitionFees, selectedTuitionDiscounts) => {
const totalFees = selectedTuitionFees.reduce((sum, feeId) => {
@ -385,7 +385,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
) : (
<p className="bg-orange-100 border border-orange-400 text-orange-700 px-4 py-3 rounded relative" role="alert">
<strong className="font-bold">Information</strong>
<span className="block sm:inline"> Aucune réduction n'a été créée sur les frais d'inscription.</span>
<span className="block sm:inline"> Aucune réduction n&apos;a été créée sur les frais d&apos;inscription.</span>
</p>
)}
</div>
@ -408,7 +408,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
) : (
<p className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<strong className="font-bold">Attention!</strong>
<span className="block sm:inline"> Aucun frais d'inscription n'a été créé.</span>
<span className="block sm:inline"> Aucun frais d&apos;inscription n&apos;a été créé.</span>
</p>
)}
</div>
@ -440,7 +440,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
) : (
<p className="bg-orange-100 border border-orange-400 text-orange-700 px-4 py-3 rounded relative" role="alert">
<strong className="font-bold">Information</strong>
<span className="block sm:inline"> Aucune réduction n'a été créée sur les frais de scolarité.</span>
<span className="block sm:inline"> Aucune réduction n&apos;a été créée sur les frais de scolarité.</span>
</p>
)}
</div>
@ -463,7 +463,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
) : (
<p className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<strong className="font-bold">Attention!</strong>
<span className="block sm:inline"> Aucun frais de scolarité n'a été créé.</span>
<span className="block sm:inline"> Aucun frais de scolarité n&apos;a été créé.</span>
</p>
)}
</div>
@ -501,7 +501,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
) : (
<p className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<strong className="font-bold">Attention!</strong>
<span className="block sm:inline"> Aucun groupe de documents n'a été créé.</span>
<span className="block sm:inline"> Aucun groupe de documents n&apos;a été créé.</span>
</p>
)}
</div>

View File

@ -249,7 +249,7 @@ export default function InscriptionFormShared({
<DjangoCSRFToken csrfToken={csrfToken}/>
{/* Section Élève */}
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
<h2 className="text-xl font-bold mb-4 text-gray-800">Informations de l'élève</h2>
<h2 className="text-xl font-bold mb-4 text-gray-800">Informations de l&apos;élève</h2>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<InputText
name="last_name"

View File

@ -49,24 +49,24 @@ const PaymentPlanSelector = ({ paymentPlans, setPaymentPlans, handleEdit, type }
}, [paymentPlans]);
useEffect(() => {
updateDefaultDay();
}, [dates, selectedFrequency]);
const updateDefaultDay = () => {
const currentDates = dates[selectedFrequency];
if (currentDates && currentDates.length > 0) {
const days = currentDates.map(date => new Date(date).getDate());
const allSameDay = days.every(day => day === days[0]);
if (allSameDay) {
setDefaultDay(days[0]);
const updateDefaultDay = () => {
const currentDates = dates[selectedFrequency];
if (currentDates && currentDates.length > 0) {
const days = currentDates.map(date => new Date(date).getDate());
const allSameDay = days.every(day => day === days[0]);
if (allSameDay) {
setDefaultDay(days[0]);
} else {
setDefaultDay('-');
setIsDefaultDayModified(false);
}
} else {
setDefaultDay('-');
setIsDefaultDayModified(false);
}
} else {
setDefaultDay('-');
}
};
};
updateDefaultDay();
}, [dates, selectedFrequency]);
const handleActivationChange = (value) => {
const selectedPlan = paymentPlans.find(plan => plan.frequency === paymentPlansOptions.find(p => p.id === value)?.frequency);

View File

@ -10,7 +10,7 @@ export default function RegistrationFileGroupList() {
return (
<div>
<h2>Groupes de fichiers d'inscription</h2>
<h2>Groupes de fichiers d&apos;inscription</h2>
<ul>
{groups.map(group => (
<li key={group.id}>{group.name}</li>

View File

@ -7,7 +7,8 @@ import SelectChoice from '@/components/SelectChoice';
import TeacherItem from '@/components/Structure/Configuration/TeacherItem';
import MultiSelect from '@/components/MultiSelect';
import LevelLabel from '@/components/CustomLabels/LevelLabel';
import { DndProvider, HTML5Backend, useDrop } from 'react-dnd';
import { DndProvider, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { ESTABLISHMENT_ID } from '@/utils/Url';
const ItemTypes = {
@ -17,16 +18,13 @@ const ItemTypes = {
const TeachersDropZone = ({ classe, handleTeachersChange, teachers, isEditing }) => {
const [localTeachers, setLocalTeachers] = useState(classe.teachers_details || []);
useEffect(() => {
}, [teachers]);
useEffect(() => {
setLocalTeachers(classe.teachers_details || []);
}, [classe.teachers_details]);
useEffect(() => {
handleTeachersChange(localTeachers.map(teacher => teacher.id));
}, [localTeachers]);
}, [handleTeachersChange, localTeachers]);
const [{ isOver, canDrop }, drop] = useDrop({
accept: ItemTypes.TEACHER,

View File

@ -27,7 +27,7 @@ const SpecialitiesDropZone = ({ teacher, handleSpecialitiesChange, specialities,
useEffect(() => {
handleSpecialitiesChange(localSpecialities.map(speciality => speciality.id));
}, [localSpecialities]);
}, [localSpecialities,handleSpecialitiesChange]);
const [{ isOver, canDrop }, drop] = useDrop({
accept: ItemTypes.SPECIALITY,

View File

@ -21,7 +21,7 @@ const PlanningClassView = ({ schedule, onDrop, selectedLevel, handleUpdatePlanni
if (schedule?.emploiDuTemps) {
setCurrentPeriod(determineInitialPeriod(schedule.emploiDuTemps));
}
}, [schedule]);
}, [schedule, determineInitialPeriod]);
if (!schedule || !schedule.emploiDuTemps) {
return (

View File

@ -22,7 +22,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
const [schedule, setSchedule] = useState(null);
const { getNiveauxTabs } = useClasses();
const niveauxLabels = Array.isArray(selectedClass?.levels) ? getNiveauxTabs(selectedClass.levels) : [];
const niveauxLabels = useMemo(() => Array.isArray(selectedClass?.levels) ? getNiveauxTabs(selectedClass.levels) : [], [selectedClass, getNiveauxTabs]);
const [isModalOpen, setIsModalOpen] = useState(false);
const handleOpenModal = () => setIsModalOpen(true);
@ -38,7 +38,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
const currentPlanning = selectedClass.plannings_read?.find(planning => planning.niveau === niveau);
setSchedule(currentPlanning ? currentPlanning.planning : {});
}
}, [selectedClass, niveauxLabels]);
}, [selectedClass, niveauxLabels, selectedLevel]);
useEffect(() => {
if (selectedClass && selectedLevel) {

View File

@ -47,7 +47,7 @@ const FeesManagement = ({ registrationDiscounts,
return (
<div className="w-full mx-auto p-2 mt-6 space-y-6">
<div className="bg-white p-2 rounded-lg shadow-md">
<h2 className="text-2xl font-semibold mb-4">Frais d'inscription</h2>
<h2 className="text-2xl font-semibold mb-4">Frais d&apos;inscription</h2>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="col-span-1 p-6 rounded-lg shadow-inner mt-4">
<FeesSection

View File

@ -21,7 +21,7 @@ const useCsrfToken = () => {
.catch(error => {
console.error('Error fetching CSRF token:', error);
});
}, []);
}, [token]);
return token;
};