mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
chore: Application du linter
This commit is contained in:
@ -8,10 +8,11 @@ import { useNotification } from '@/context/NotificationContext';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import AlertMessage from '@/components/AlertMessage';
|
||||
import RecipientInput from '@/components/RecipientInput';
|
||||
|
||||
// Charger Quill dynamiquement pour éviter les problèmes de SSR
|
||||
const ReactQuill = dynamic(() => import('react-quill'), { ssr: false });
|
||||
import 'react-quill/dist/quill.snow.css'; // Importer les styles de Quill
|
||||
import { useRouter } from 'next/navigation'; // Ajoute cette ligne
|
||||
import WisiwigTextArea from '@/components/WisiwigTextArea';
|
||||
import logger from '@/utils/logger';
|
||||
import InputText from '@/components/InputText';
|
||||
import Button from '@/components/Button';
|
||||
|
||||
export default function EmailSender({ csrfToken }) {
|
||||
const [recipients, setRecipients] = useState([]);
|
||||
@ -23,6 +24,7 @@ export default function EmailSender({ csrfToken }) {
|
||||
const [smtpConfigured, setSmtpConfigured] = useState(false); // État pour vérifier si SMTP est configuré
|
||||
const { showNotification } = useNotification();
|
||||
const { selectedEstablishmentId } = useEstablishment(); // Récupérer l'establishment_id depuis le contexte
|
||||
const router = useRouter(); // Ajoute cette ligne
|
||||
|
||||
useEffect(() => {
|
||||
// Vérifier si les paramètres SMTP sont configurés
|
||||
@ -36,10 +38,9 @@ export default function EmailSender({ csrfToken }) {
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(
|
||||
'Erreur lors de la vérification des paramètres SMTP:',
|
||||
error
|
||||
);
|
||||
logger.error('Erreur lors de la vérification des paramètres SMTP:', {
|
||||
error,
|
||||
});
|
||||
setSmtpConfigured(false);
|
||||
});
|
||||
}, [csrfToken, selectedEstablishmentId]);
|
||||
@ -64,7 +65,7 @@ export default function EmailSender({ csrfToken }) {
|
||||
setSubject('');
|
||||
setMessage('');
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de l'envoi de l'email:", error);
|
||||
logger.error("Erreur lors de l'envoi de l'email:", { error });
|
||||
showNotification(
|
||||
"Une erreur est survenue lors de l'envoi de l'email.",
|
||||
'error',
|
||||
@ -80,82 +81,76 @@ export default function EmailSender({ csrfToken }) {
|
||||
title="Configuration SMTP requise"
|
||||
message="Les paramètres SMTP de cet établissement ne sont pas configurés. Veuillez les configurer dans la page des paramètres."
|
||||
actionLabel="Aller aux paramètres"
|
||||
onAction={() => (window.location.href = '/admin/settings')} // Redirige vers la page des paramètres
|
||||
onAction={() => router.push('/admin/settings?tab=smtp')} // Utilise next/navigation ici
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto bg-white rounded-lg shadow-md">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-4 py-2 border-b">
|
||||
<h2 className="text-sm font-medium text-gray-700">
|
||||
Email from {fromEmail}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<div className="p-4">
|
||||
{/* To */}
|
||||
<div className="p-4 flex flex-col min-h-[600px]">
|
||||
{' '}
|
||||
{/* Ajout flex-col et min-h */}
|
||||
{/* Destinataires */}
|
||||
<RecipientInput
|
||||
label="Destinataires"
|
||||
recipients={recipients}
|
||||
setRecipients={setRecipients}
|
||||
searchRecipients={searchRecipients} // Passer l'action de recherche
|
||||
establishmentId={selectedEstablishmentId} // Passer l'ID de l'établissement
|
||||
searchRecipients={searchRecipients}
|
||||
establishmentId={selectedEstablishmentId}
|
||||
required
|
||||
/>
|
||||
|
||||
{/* Cc and Bcc */}
|
||||
<div className="flex space-x-4">
|
||||
{/* Cc */}
|
||||
<div className="mt-2">
|
||||
<RecipientInput
|
||||
label="Cc"
|
||||
placeholder="Add Cc"
|
||||
placeholder="Ajouter Cc"
|
||||
recipients={cc}
|
||||
searchRecipients={searchRecipients}
|
||||
establishmentId={selectedEstablishmentId}
|
||||
setRecipients={setCc}
|
||||
/>
|
||||
</div>
|
||||
{/* Bcc */}
|
||||
<div className="mt-2">
|
||||
<RecipientInput
|
||||
label="Bcc"
|
||||
placeholder="Add Bcc"
|
||||
label="Cci"
|
||||
placeholder="Ajouter Bcc"
|
||||
recipients={bcc}
|
||||
searchRecipients={searchRecipients}
|
||||
establishmentId={selectedEstablishmentId}
|
||||
setRecipients={setBcc}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Subject */}
|
||||
<div className="mb-4">
|
||||
<label className="block text-sm font-medium text-gray-700">
|
||||
Subject
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={subject}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
placeholder="Enter subject"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputText
|
||||
name="subject"
|
||||
label="Sujet"
|
||||
value={subject}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
placeholder="Saisir le sujet"
|
||||
className="mb-4 mt-2"
|
||||
required
|
||||
/>
|
||||
{/* Email Body */}
|
||||
<div className="mb-4">
|
||||
<label className="block text-sm font-medium text-gray-700">
|
||||
Your email
|
||||
</label>
|
||||
<ReactQuill
|
||||
theme="snow"
|
||||
<div className="mb-4 flex flex-col">
|
||||
<WisiwigTextArea
|
||||
label="Mail"
|
||||
value={message}
|
||||
onChange={setMessage}
|
||||
placeholder="Write your email here..."
|
||||
placeholder="Ecrivez votre mail ici..."
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="flex justify-between items-center">
|
||||
<button
|
||||
<div className="flex justify-between items-center mt-10">
|
||||
<Button
|
||||
text="Envoyer"
|
||||
onClick={handleSendEmail}
|
||||
className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600"
|
||||
>
|
||||
Send email
|
||||
</button>
|
||||
primary
|
||||
className="px-4 py-2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user