From 6edf1f6724241671d3bc2e6109b3fcd325f33df7 Mon Sep 17 00:00:00 2001 From: Manus Date: Fri, 17 Apr 2026 07:27:41 -0400 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20-=20Bouton=20crayon=20dans=20MesE?= =?UTF-8?q?tablissements=20ouvre=20un=20Dialog=20modal=20(sans=20mode=20?= =?UTF-8?q?=C3=A9dition=20pr=C3=A9alable)=20-=20Page=20Solutions=20Logicie?= =?UTF-8?q?lles=20:=20bouton=20Ajouter,=20crayon=20Modifier,=20poubelle=20?= =?UTF-8?q?Supprimer=20(gestionnaires=20uniquement)=20-=20Lien=20espace=20?= =?UTF-8?q?adh=C3=A9rent=20FEHAP=20mis=20=C3=A0=20jour=20vers=20l'URL=20ex?= =?UTF-8?q?acte=20-=20Serveur=20red=C3=A9marr=C3=A9,=20cache=20esbuild=20p?= =?UTF-8?q?urg=C3=A9,=200=20erreur=20TypeScript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/SonumLayout.tsx | 2 +- client/src/pages/MesEtablissements.tsx | 312 ++++++++-------------- client/src/pages/SolutionsLogicielles.tsx | 239 +++++++++-------- server/db.ts | 14 + server/routers.ts | 19 ++ 5 files changed, 272 insertions(+), 314 deletions(-) diff --git a/client/src/components/SonumLayout.tsx b/client/src/components/SonumLayout.tsx index 4f11b34..ace5f09 100644 --- a/client/src/components/SonumLayout.tsx +++ b/client/src/components/SonumLayout.tsx @@ -176,7 +176,7 @@ export default function SonumLayout({ children }: { children: React.ReactNode }) {/* Footer sidebar */}
(null); - const [editMode, setEditMode] = useState(null); const [rattacherEtab, setRattacherEtab] = useState<{ id: number; nom: string } | null>(null); - const etablissementsQuery = trpc.etablissements.mesEtablissements.useQuery(); const utils = trpc.useUtils(); - const toggleAccordion = (id: number) => { - setOpenEtab(openEtab === id ? null : id); - setEditMode(null); - }; + const toggleAccordion = (id: number) => setOpenEtab(openEtab === id ? null : id); if (etablissementsQuery.isLoading) { return ( @@ -50,13 +36,10 @@ export default function MesEtablissements() { return (
- {/* En-tête */}

Mes Établissements

-

- Gérez les logiciels de vos établissements rattachés -

+

Gérez les logiciels de vos établissements rattachés

@@ -68,9 +51,7 @@ export default function MesEtablissements() {

Aucun établissement rattaché

-

- Contactez un gestionnaire SONUM pour rattacher vos établissements. -

+

Contactez un gestionnaire SONUM pour rattacher vos établissements.

) : (
@@ -79,12 +60,9 @@ export default function MesEtablissements() { key={etab.id} etab={etab} isOpen={openEtab === etab.id} - isEditMode={editMode === etab.id} onToggle={() => toggleAccordion(etab.id)} - onEditMode={() => setEditMode(editMode === etab.id ? null : etab.id)} onRattacher={() => setRattacherEtab({ id: etab.id, nom: etab.nom })} onViewFiche={() => navigate(`/etablissement/${etab.id}`)} - onRefresh={() => utils.etablissements.mesEtablissements.invalidate()} /> ))}
@@ -106,44 +84,17 @@ export default function MesEtablissements() { ); } -function EtablissementAccordion({ - etab, - isOpen, - isEditMode, - onToggle, - onEditMode, - onRattacher, - onViewFiche, - onRefresh, -}: { - etab: any; - isOpen: boolean; - isEditMode: boolean; - onToggle: () => void; - onEditMode: () => void; - onRattacher: () => void; - onViewFiche: () => void; - onRefresh: () => void; +function EtablissementAccordion({ etab, isOpen, onToggle, onRattacher, onViewFiche }: { + etab: any; isOpen: boolean; onToggle: () => void; onRattacher: () => void; onViewFiche: () => void; }) { - const logicielsQuery = trpc.logiciels.byEtablissement.useQuery( - { etablissementId: etab.id }, - { enabled: isOpen } - ); + const logicielsQuery = trpc.logiciels.byEtablissement.useQuery({ etablissementId: etab.id }, { enabled: isOpen }); const deleteMutation = trpc.logiciels.delete.useMutation({ - onSuccess: () => { - toast.success("Logiciel supprimé"); - logicielsQuery.refetch(); - }, + onSuccess: () => { toast.success("Logiciel supprimé"); logicielsQuery.refetch(); }, }); - const utils = trpc.useUtils(); return ( -
- {/* En-tête accordéon */} - - {/* Contenu accordéon */} {isOpen && (
- {/* Barre d'actions */}
-
- - -
- +
- {/* Tableau des logiciels */} {logicielsQuery.isLoading ? (
) : !logicielsQuery.data?.length ? (
-

Aucun logiciel renseigné pour cet établissement.

- +

Aucun logiciel renseigné.

+
) : (
@@ -229,9 +144,7 @@ function EtablissementAccordion({ Bloc fonctionnel État Hébergement - {isEditMode && ( - Actions - )} + Actions @@ -239,7 +152,6 @@ function EtablissementAccordion({ deleteMutation.mutate({ id: logiciel.id, etablissementId: etab.id })} onUpdated={() => logicielsQuery.refetch()} @@ -255,115 +167,101 @@ function EtablissementAccordion({ ); } -function LogicielRow({ - logiciel, - isEditMode, - etablissementId, - onDelete, - onUpdated, -}: { - logiciel: any; - isEditMode: boolean; - etablissementId: number; - onDelete: () => void; - onUpdated: () => void; +function LogicielRow({ logiciel, etablissementId, onDelete, onUpdated }: { + logiciel: any; etablissementId: number; onDelete: () => void; onUpdated: () => void; }) { - const [editing, setEditing] = useState(false); - const [etat, setEtat] = useState(logiciel.etatDeploiement); + const [open, setOpen] = useState(false); + const [etat, setEtat] = useState(logiciel.etatDeploiement ?? "operationnel"); + const [hebergement, setHebergement] = useState(logiciel.modeHebergement ?? ""); + const [facturation, setFacturation] = useState(logiciel.modeFacturation ?? ""); const [commentaire, setCommentaire] = useState(logiciel.commentaire ?? ""); const updateMutation = trpc.logiciels.upsert.useMutation({ - onSuccess: () => { - toast.success("Logiciel mis à jour"); - setEditing(false); - onUpdated(); - }, + onSuccess: () => { toast.success("Logiciel mis à jour"); setOpen(false); onUpdated(); }, + onError: (e) => toast.error("Erreur : " + e.message), }); - if (editing && isEditMode) { - return ( - - {logiciel.solutionNom} - {logiciel.editeurNom} - {logiciel.blocFonctionnelNom} - - - - - setCommentaire(e.target.value)} - placeholder="Commentaire..." - className="text-xs border border-border rounded px-2 py-1 bg-background w-full" - /> - - -
- - -
- - - ); - } + const handleOpen = () => { + setEtat(logiciel.etatDeploiement ?? "operationnel"); + setHebergement(logiciel.modeHebergement ?? ""); + setFacturation(logiciel.modeFacturation ?? ""); + setCommentaire(logiciel.commentaire ?? ""); + setOpen(true); + }; return ( - - {logiciel.solutionNom} - {logiciel.editeurNom} - - {logiciel.blocFonctionnelNom && ( - - {logiciel.blocFonctionnelNom} - - )} - - - - - - {logiciel.modeHebergement ? : } - - {isEditMode && ( + <> + + {logiciel.solutionNom} + {logiciel.editeurNom} + + {logiciel.blocFonctionnelNom && {logiciel.blocFonctionnelNom}} + + + + {logiciel.modeHebergement ? : } +
- -
- )} - + + + + + + Modifier — {logiciel.solutionNom} + +
+
+ + +
+
+ + +
+
+ + +
+
+ +