Added few functions to the platform

This commit is contained in:
2026-02-06 11:34:16 +01:00
parent bb5c3058b1
commit ccff904464
14 changed files with 2770 additions and 74 deletions

View File

@@ -1,6 +1,7 @@
'use client';
import { useState, useEffect } from 'react';
import AlertModal from './AlertModal';
interface Adherent {
id: string;
@@ -26,6 +27,12 @@ interface AdherentFormProps {
export default function AdherentForm({ adherent, onClose }: AdherentFormProps) {
const [loading, setLoading] = useState(false);
const [alertModal, setAlertModal] = useState<{
show: boolean;
type: 'success' | 'error' | 'info' | 'warning';
title: string;
message: string;
} | null>(null);
const [options, setOptions] = useState<{
situation: Array<{ id: string; value: string }>;
prescripteur: Array<{ id: string; value: string }>;
@@ -126,11 +133,21 @@ export default function AdherentForm({ adherent, onClose }: AdherentFormProps) {
onClose();
} else {
const error = await response.json();
alert(error.error || 'Une erreur est survenue');
setAlertModal({
show: true,
type: 'error',
title: 'Erreur',
message: error.error || 'Une erreur est survenue',
});
}
} catch (error) {
console.error('Erreur:', error);
alert('Une erreur est survenue');
setAlertModal({
show: true,
type: 'error',
title: 'Erreur',
message: 'Une erreur est survenue',
});
} finally {
setLoading(false);
}
@@ -492,6 +509,17 @@ export default function AdherentForm({ adherent, onClose }: AdherentFormProps) {
</div>
</form>
</div>
{/* Modal d'alerte */}
{alertModal && (
<AlertModal
isOpen={alertModal.show}
type={alertModal.type}
title={alertModal.title}
message={alertModal.message}
onClose={() => setAlertModal(null)}
/>
)}
</div>
);
}