From 5e81fd7e79183aed628ad299fb0467af37fed233 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Thu, 26 Dec 2024 09:31:46 +0100 Subject: [PATCH 01/14] refactor: change link to panier --- .../src/app/Layout/Header/makeNavItems.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts b/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts index 5da8e4048b..1f983c563e 100644 --- a/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts +++ b/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts @@ -59,6 +59,13 @@ const makeNavItemsBase = ( to: makeCollectiviteAccueilUrl({ collectiviteId }), dataTest: 'nav-home', }, + { + label: 'Actions à Impact', + dataTest: 'pa-actions-impact', + to: makeCollectivitePanierUrl({ + collectiviteId, + }), + }, { confidentiel, label: 'Actions à Impact', From c729fb46ab68b9cae7af23ecca23c4df93d33e30 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:17:31 +0100 Subject: [PATCH 02/14] feat: trigger setEditFiche when a tag is edited (all tags except personnes-related) --- .../PlansActions/FicheAction/utils.ts | 22 +++++++++++++++++++ .../PartenairesDropdown.tsx | 2 ++ .../ServicesPilotesDropdown.tsx | 2 ++ .../StructuresDropdown/StructuresDropdown.tsx | 2 ++ .../TagsSuiviPersoDropdown.tsx | 2 ++ .../src/ui/dropdownLists/tags/SelectTags.tsx | 9 ++++++-- 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts index e17e276831..8de24b68ae 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts @@ -14,3 +14,25 @@ export const statutToColor: Record = { 'Sans statut': preset.theme.extend.colors.grey[4], NC: preset.theme.extend.colors.grey[3], }; + +/** + * Updates a tag in a list of tags + * Valid for tags with id, collectiviteId and nom + * (! not valid for personnes tags, since they have a different structure) + * @param tags Original list of tags + * @param editedTag Modified tag + * @returns New list with updated tag + */ +export const updateFicheActionTagInList = ( + list: + | { id: number; collectiviteId: number; nom: string }[] + | null + | undefined, + editedTag: { id: number; collectiviteId: number; nom: string } +) => { + const existingTags = list ?? []; + return existingTags.map((tag) => ({ + ...tag, + ...(tag.id === editedTag.id ? editedTag : {}), + })); +}; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx index bd9d5affb4..e0e7245fc1 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx @@ -15,6 +15,7 @@ type PartenairesDropdownProps = Omit< partenaires: Tag[]; selectedPartenaire: Tag; }) => void; + onTagEdit?: (editedTag: Tag) => void; }; const PartenairesDropdown = (props: PartenairesDropdownProps) => { @@ -34,6 +35,7 @@ const PartenairesDropdown = (props: PartenairesDropdownProps) => { selectedPartenaire: selectedValue, }); }} + onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx index 1b191dcb10..3164903a9f 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx @@ -16,6 +16,7 @@ type ServicesPilotesDropdownProps = Omit< selectedService: Tag; }) => void; disabledOptionsIds?: number[]; + onTagEdit?: (editedTag: Tag) => void; }; const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { @@ -35,6 +36,7 @@ const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { selectedService: selectedValue, }); }} + onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx index 91e42c3fe6..b4c5d7bfb8 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx @@ -15,6 +15,7 @@ type StructuresDropdownProps = Omit< structures: Tag[]; selectedStructure: Tag; }) => void; + onTagEdit?: (editedTag: Tag) => void; }; const StructuresDropdown = (props: StructuresDropdownProps) => { @@ -34,6 +35,7 @@ const StructuresDropdown = (props: StructuresDropdownProps) => { selectedStructure: selectedValue, }); }} + onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx index b2e8752a43..7f00262d3c 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx @@ -15,6 +15,7 @@ type TagsSuiviPersoDropdownProps = Omit< libresTag: Tag[]; selectedLibreTag: Tag; }) => void; + onTagEdit?: (editedTag: Tag) => void; }; const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { @@ -34,6 +35,7 @@ const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { selectedLibreTag: selectedValue, }); }} + onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index c3048a64ba..4cf0160951 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -20,6 +20,7 @@ type SelectTagsProps = Omit & { values: Tag[]; selectedValue: Tag; }) => void; + onTagEdit?: (editedTag: Tag) => void; }; const SelectTags = ({ @@ -29,6 +30,7 @@ const SelectTags = ({ userCreatedOptionsIds, disabledOptionsIds, refetchOptions, + onTagEdit, ...props }: SelectTagsProps) => { const collectiviteId = useCollectiviteId(); @@ -93,11 +95,14 @@ const SelectTags = ({ }); const handleTagUpdate = (tagId: OptionValue, tagName: string) => { - updateTag({ + const editedTag = { collectiviteId: collectiviteId!, id: parseInt(tagId as string), nom: tagName, - }); + }; + + updateTag(editedTag); + onTagEdit?.(editedTag); }; // *** From 209154b12a24166f466795922a1cc2e49bf79938 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:41:50 +0100 Subject: [PATCH 03/14] feat: add trigger when a tag is edited in ModaleActeurs and ModaleDescription components --- .../FicheActionActeurs/ModaleActeurs.tsx | 28 +++++++++++++++++++ .../ModaleDescription.tsx | 16 +++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx index 3d62a98068..53eb31dab6 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx @@ -17,6 +17,7 @@ import { } from '@/ui'; import _ from 'lodash'; import { useState } from 'react'; +import { updateFicheActionTagInList } from '../utils'; type ModaleActeursProps = { isOpen: boolean; @@ -61,6 +62,15 @@ const ModaleActeurs = ({ services, })) } + onTagEdit={(editedTag) => { + setEditedFiche((prevState) => ({ + ...prevState, + services: updateFicheActionTagInList( + prevState.services, + editedTag + ), + })); + }} /> @@ -74,6 +84,15 @@ const ModaleActeurs = ({ structures, })) } + onTagEdit={(editedTag) => { + setEditedFiche((prevState) => ({ + ...prevState, + structures: updateFicheActionTagInList( + prevState.structures, + editedTag + ), + })); + }} /> @@ -101,6 +120,15 @@ const ModaleActeurs = ({ partenaires, })) } + onTagEdit={(editedTag) => { + setEditedFiche((prevState) => ({ + ...prevState, + partenaires: updateFicheActionTagInList( + prevState.partenaires, + editedTag + ), + })); + }} /> diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 564b6f781c..20b25914d5 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -17,6 +17,7 @@ import { } from '@/ui'; import _ from 'lodash'; import { useState } from 'react'; +import { updateFicheActionTagInList } from '../utils'; const DESCRIPTION_MAX_LENGTH = 20000; const MOYENS_MAX_LENGTH = 10000; @@ -100,9 +101,18 @@ const ModaleDescription = ({ fiche, updateFiche }: ModaleDescriptionProps) => { t.id)} - onChange={({ libresTag }) => - setEditedFiche((prevState) => ({ ...prevState, libresTag })) - } + onChange={({ libresTag }) => { + setEditedFiche((prevState) => ({ ...prevState, libresTag })); + }} + onTagEdit={(editedTag) => { + setEditedFiche((prevState) => ({ + ...prevState, + libresTag: updateFicheActionTagInList( + prevState.libresTag, + editedTag + ), + })); + }} /> From a07d14930d69dee794d78b03937fa83228133e7d Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:10:55 +0100 Subject: [PATCH 04/14] refactor: remove onTagEdit handlers from dropdown components --- .../FicheActionActeurs/ModaleActeurs.tsx | 27 ------------------- .../ModaleDescription.tsx | 9 ------- .../PartenairesDropdown.tsx | 2 -- .../ServicesPilotesDropdown.tsx | 2 -- .../StructuresDropdown/StructuresDropdown.tsx | 2 -- .../TagsSuiviPersoDropdown.tsx | 2 -- 6 files changed, 44 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx index 53eb31dab6..060608a4e4 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx @@ -62,15 +62,6 @@ const ModaleActeurs = ({ services, })) } - onTagEdit={(editedTag) => { - setEditedFiche((prevState) => ({ - ...prevState, - services: updateFicheActionTagInList( - prevState.services, - editedTag - ), - })); - }} /> @@ -84,15 +75,6 @@ const ModaleActeurs = ({ structures, })) } - onTagEdit={(editedTag) => { - setEditedFiche((prevState) => ({ - ...prevState, - structures: updateFicheActionTagInList( - prevState.structures, - editedTag - ), - })); - }} /> @@ -120,15 +102,6 @@ const ModaleActeurs = ({ partenaires, })) } - onTagEdit={(editedTag) => { - setEditedFiche((prevState) => ({ - ...prevState, - partenaires: updateFicheActionTagInList( - prevState.partenaires, - editedTag - ), - })); - }} /> diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 20b25914d5..73342d7f16 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -104,15 +104,6 @@ const ModaleDescription = ({ fiche, updateFiche }: ModaleDescriptionProps) => { onChange={({ libresTag }) => { setEditedFiche((prevState) => ({ ...prevState, libresTag })); }} - onTagEdit={(editedTag) => { - setEditedFiche((prevState) => ({ - ...prevState, - libresTag: updateFicheActionTagInList( - prevState.libresTag, - editedTag - ), - })); - }} /> diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx index e0e7245fc1..bd9d5affb4 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx @@ -15,7 +15,6 @@ type PartenairesDropdownProps = Omit< partenaires: Tag[]; selectedPartenaire: Tag; }) => void; - onTagEdit?: (editedTag: Tag) => void; }; const PartenairesDropdown = (props: PartenairesDropdownProps) => { @@ -35,7 +34,6 @@ const PartenairesDropdown = (props: PartenairesDropdownProps) => { selectedPartenaire: selectedValue, }); }} - onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx index 3164903a9f..1b191dcb10 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx @@ -16,7 +16,6 @@ type ServicesPilotesDropdownProps = Omit< selectedService: Tag; }) => void; disabledOptionsIds?: number[]; - onTagEdit?: (editedTag: Tag) => void; }; const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { @@ -36,7 +35,6 @@ const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { selectedService: selectedValue, }); }} - onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx index b4c5d7bfb8..91e42c3fe6 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx @@ -15,7 +15,6 @@ type StructuresDropdownProps = Omit< structures: Tag[]; selectedStructure: Tag; }) => void; - onTagEdit?: (editedTag: Tag) => void; }; const StructuresDropdown = (props: StructuresDropdownProps) => { @@ -35,7 +34,6 @@ const StructuresDropdown = (props: StructuresDropdownProps) => { selectedStructure: selectedValue, }); }} - onTagEdit={props.onTagEdit} /> ); }; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx index 7f00262d3c..b2e8752a43 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx @@ -15,7 +15,6 @@ type TagsSuiviPersoDropdownProps = Omit< libresTag: Tag[]; selectedLibreTag: Tag; }) => void; - onTagEdit?: (editedTag: Tag) => void; }; const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { @@ -35,7 +34,6 @@ const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { selectedLibreTag: selectedValue, }); }} - onTagEdit={props.onTagEdit} /> ); }; From b4fbb104dfc366e90955d1e14f3fcaed926ec0f8 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:38:23 +0100 Subject: [PATCH 05/14] feat: update tag handling in SelectTags component to trigger onChange with updated tag data --- .../src/ui/dropdownLists/tags/SelectTags.tsx | 25 +++++++++++++++---- .../src/ui/dropdownLists/tags/useTagUpdate.ts | 12 ++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index 4cf0160951..1648417a10 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -20,7 +20,6 @@ type SelectTagsProps = Omit & { values: Tag[]; selectedValue: Tag; }) => void; - onTagEdit?: (editedTag: Tag) => void; }; const SelectTags = ({ @@ -30,7 +29,6 @@ const SelectTags = ({ userCreatedOptionsIds, disabledOptionsIds, refetchOptions, - onTagEdit, ...props }: SelectTagsProps) => { const collectiviteId = useCollectiviteId(); @@ -88,7 +86,7 @@ const SelectTags = ({ // Mise à jour d'un tag de la liste d'options // *** - const { mutate: updateTag } = useTagUpdate({ + const { data: updatedTag, mutate: updateTag } = useTagUpdate({ key: [queryKey, collectiviteId], tagTableName, onSuccess: refetchOptions, @@ -100,11 +98,28 @@ const SelectTags = ({ id: parseInt(tagId as string), nom: tagName, }; - updateTag(editedTag); - onTagEdit?.(editedTag); }; + useEffect(() => { + if (updatedTag) { + const tag = { + collectiviteId: collectiviteId!, + nom: updatedTag.nom, + id: updatedTag.id, + }; + + const otherTags = getSelectedValues(props.values).filter( + (t) => t.id !== tag.id + ); + + props.onChange({ + values: [tag, ...otherTags], + selectedValue: tag, + }); + } + }, [updatedTag]); + // *** // Suppression d'un tag de la liste d'options // *** diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts index 3f4b40a70f..29705303d2 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts @@ -21,11 +21,17 @@ export const useTagUpdate = ({ return useMutation( async (tag: TagUpdate) => { - if (tag.id) - await supabaseClient + if (tag.id) { + const { data, error } = await supabaseClient .from(tagTableName) .update(objectToSnake(tag)) - .eq('id', tag.id); + .eq('id', tag.id) + .select() + .single(); + + if (error) throw error; + return data; + } }, { mutationKey: 'update_tag', From f9ebd35d7fe7f398902149ab308c63ea5807dbb5 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:24:35 +0100 Subject: [PATCH 06/14] =?UTF-8?q?refactor:=20remove=20'Actions=20=C3=A0=20?= =?UTF-8?q?Impact'=20navigation=20item=20from=20Header=20(make=20it=20iso?= =?UTF-8?q?=20with=20main)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/Layout/Header/makeNavItems.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts b/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts index 1f983c563e..5da8e4048b 100644 --- a/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts +++ b/app.territoiresentransitions.react/src/app/Layout/Header/makeNavItems.ts @@ -59,13 +59,6 @@ const makeNavItemsBase = ( to: makeCollectiviteAccueilUrl({ collectiviteId }), dataTest: 'nav-home', }, - { - label: 'Actions à Impact', - dataTest: 'pa-actions-impact', - to: makeCollectivitePanierUrl({ - collectiviteId, - }), - }, { confidentiel, label: 'Actions à Impact', From 5bce6d5c79ff75c8aaeb11685948c0176f8f291a Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:30:58 +0100 Subject: [PATCH 07/14] refactor: remove updateFicheActionTagInList function and its imports --- .../FicheActionActeurs/ModaleActeurs.tsx | 1 - .../ModaleDescription.tsx | 1 - .../PlansActions/FicheAction/utils.ts | 22 ------------------- 3 files changed, 24 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx index 060608a4e4..3d62a98068 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx @@ -17,7 +17,6 @@ import { } from '@/ui'; import _ from 'lodash'; import { useState } from 'react'; -import { updateFicheActionTagInList } from '../utils'; type ModaleActeursProps = { isOpen: boolean; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 73342d7f16..9ec4cbb456 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -17,7 +17,6 @@ import { } from '@/ui'; import _ from 'lodash'; import { useState } from 'react'; -import { updateFicheActionTagInList } from '../utils'; const DESCRIPTION_MAX_LENGTH = 20000; const MOYENS_MAX_LENGTH = 10000; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts index 8de24b68ae..e17e276831 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts @@ -14,25 +14,3 @@ export const statutToColor: Record = { 'Sans statut': preset.theme.extend.colors.grey[4], NC: preset.theme.extend.colors.grey[3], }; - -/** - * Updates a tag in a list of tags - * Valid for tags with id, collectiviteId and nom - * (! not valid for personnes tags, since they have a different structure) - * @param tags Original list of tags - * @param editedTag Modified tag - * @returns New list with updated tag - */ -export const updateFicheActionTagInList = ( - list: - | { id: number; collectiviteId: number; nom: string }[] - | null - | undefined, - editedTag: { id: number; collectiviteId: number; nom: string } -) => { - const existingTags = list ?? []; - return existingTags.map((tag) => ({ - ...tag, - ...(tag.id === editedTag.id ? editedTag : {}), - })); -}; From 1f341078f30770c292be67f86a2d144ee8040ab6 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:33:30 +0100 Subject: [PATCH 08/14] refactor: remove useless constant --- .../src/ui/dropdownLists/tags/SelectTags.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index 1648417a10..d9dcb82722 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -93,12 +93,11 @@ const SelectTags = ({ }); const handleTagUpdate = (tagId: OptionValue, tagName: string) => { - const editedTag = { + updateTag({ collectiviteId: collectiviteId!, id: parseInt(tagId as string), nom: tagName, - }; - updateTag(editedTag); + }); }; useEffect(() => { From 32ee808ac4fb80ad16cf79388be730dc82553045 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:34:47 +0100 Subject: [PATCH 09/14] refactor: simplify onChange handler for TagsSuiviPersoDropdown --- .../FicheActionDescription/ModaleDescription.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 9ec4cbb456..564b6f781c 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -100,9 +100,9 @@ const ModaleDescription = ({ fiche, updateFiche }: ModaleDescriptionProps) => { t.id)} - onChange={({ libresTag }) => { - setEditedFiche((prevState) => ({ ...prevState, libresTag })); - }} + onChange={({ libresTag }) => + setEditedFiche((prevState) => ({ ...prevState, libresTag })) + } /> From 0bb076ee0e5514aedfa7ce40a4e16f99d90fa025 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:38:02 +0100 Subject: [PATCH 10/14] refactor: add additionalKeysToInvalidate to support cache invalidation for fiche_action when a tag is updated --- .../FicheActionActeurs/ModaleActeurs.tsx | 12 ++++++++++ .../ModaleDescription.tsx | 3 +++ .../FicheActionPilotes/ModalePilotes.tsx | 3 +++ .../PartenairesDropdown.tsx | 3 +++ .../PersonnesDropdown/PersonnesDropdown.tsx | 3 +++ .../ServicesPilotesDropdown.tsx | 3 +++ .../StructuresDropdown/StructuresDropdown.tsx | 3 +++ .../TagsSuiviPersoDropdown.tsx | 3 +++ .../src/ui/dropdownLists/tags/SelectTags.tsx | 22 +++---------------- .../src/ui/dropdownLists/tags/useTagUpdate.ts | 16 +++++--------- 10 files changed, 42 insertions(+), 29 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx index 3d62a98068..a1065460e5 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx @@ -61,6 +61,9 @@ const ModaleActeurs = ({ services, })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> @@ -74,6 +77,9 @@ const ModaleActeurs = ({ structures, })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> @@ -88,6 +94,9 @@ const ModaleActeurs = ({ referents: personnes, })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> @@ -101,6 +110,9 @@ const ModaleActeurs = ({ partenaires, })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 564b6f781c..ad619fdae8 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -103,6 +103,9 @@ const ModaleDescription = ({ fiche, updateFiche }: ModaleDescriptionProps) => { onChange={({ libresTag }) => setEditedFiche((prevState) => ({ ...prevState, libresTag })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionPilotes/ModalePilotes.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionPilotes/ModalePilotes.tsx index 4526859267..9b9382d482 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionPilotes/ModalePilotes.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionPilotes/ModalePilotes.tsx @@ -45,6 +45,9 @@ const ModalePilotes = ({ pilotes: personnes, })) } + additionalKeysToInvalidate={[ + ['fiche_action', fiche.id.toString()], + ]} /> diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx index bd9d5affb4..30d8e8e07c 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx @@ -2,6 +2,7 @@ import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { usePartenairesListe } from './usePartenairesListe'; +import { QueryKey } from 'react-query'; type PartenairesDropdownProps = Omit< SelectMultipleProps, @@ -15,6 +16,7 @@ type PartenairesDropdownProps = Omit< partenaires: Tag[]; selectedPartenaire: Tag; }) => void; + additionalKeysToInvalidate?: QueryKey[]; }; const PartenairesDropdown = (props: PartenairesDropdownProps) => { @@ -26,6 +28,7 @@ const PartenairesDropdown = (props: PartenairesDropdownProps) => { placeholder={props.placeholder ?? 'Sélectionnez ou créez un partenaire'} queryKey="partenaires" tagTableName="partenaire_tag" + additionalKeysToInvalidate={props.additionalKeysToInvalidate} optionsListe={data} refetchOptions={refetch} onChange={({ values, selectedValue }) => { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx index 1f8ef979b0..7cfbaf1b9e 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx @@ -9,6 +9,7 @@ import { Option, OptionValue, SelectFilter, SelectMultipleProps } from '@/ui'; import { Personne } from '@/api/collectivites'; import { usePersonneListe } from './usePersonneListe'; import { getPersonneStringId } from './utils'; +import { QueryKey } from 'react-query'; type Props = Omit & { values?: string[]; @@ -21,6 +22,7 @@ type Props = Omit & { }) => void; disabledOptionsIds?: string[]; disableEdition?: boolean; + additionalKeysToInvalidate?: QueryKey[]; }; /** Sélecteur de personnes de la collectivité */ @@ -47,6 +49,7 @@ const PersonnesDropdown = (props: Props) => { const { mutate: updateTag } = useTagUpdate({ key: ['personnes', collectiviteId], tagTableName: 'personne_tag', + keysToInvalidate: props.additionalKeysToInvalidate, }); const { mutate: deleteTag } = useDeleteTag({ diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx index 1b191dcb10..bbb8cba6b2 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx @@ -2,6 +2,7 @@ import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useServicesPilotesListe } from './useServicesPilotesListe'; +import { QueryKey } from 'react-query'; type ServicesPilotesDropdownProps = Omit< SelectMultipleProps, @@ -16,6 +17,7 @@ type ServicesPilotesDropdownProps = Omit< selectedService: Tag; }) => void; disabledOptionsIds?: number[]; + additionalKeysToInvalidate?: QueryKey[]; }; const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { @@ -27,6 +29,7 @@ const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => { dataTest={props.dataTest ?? 'ServicePilote'} queryKey="services_pilotes" tagTableName="service_tag" + additionalKeysToInvalidate={props.additionalKeysToInvalidate} optionsListe={data} refetchOptions={refetch} onChange={({ values, selectedValue }) => { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx index 91e42c3fe6..99fe775a50 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx @@ -2,6 +2,7 @@ import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useStructuresListe } from './useStructuresListe'; +import { QueryKey } from 'react-query'; type StructuresDropdownProps = Omit< SelectMultipleProps, @@ -15,6 +16,7 @@ type StructuresDropdownProps = Omit< structures: Tag[]; selectedStructure: Tag; }) => void; + additionalKeysToInvalidate?: QueryKey[]; }; const StructuresDropdown = (props: StructuresDropdownProps) => { @@ -26,6 +28,7 @@ const StructuresDropdown = (props: StructuresDropdownProps) => { placeholder={props.placeholder ?? 'Sélectionnez ou créez un pilote'} queryKey="structures" tagTableName="structure_tag" + additionalKeysToInvalidate={props.additionalKeysToInvalidate} optionsListe={data} refetchOptions={refetch} onChange={({ values, selectedValue }) => { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx index b2e8752a43..d44ed1719f 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx @@ -2,6 +2,7 @@ import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useTagsSuiviPersoListe } from './useTagsSuiviPersoListe'; +import { QueryKey } from 'react-query'; type TagsSuiviPersoDropdownProps = Omit< SelectMultipleProps, @@ -15,6 +16,7 @@ type TagsSuiviPersoDropdownProps = Omit< libresTag: Tag[]; selectedLibreTag: Tag; }) => void; + additionalKeysToInvalidate?: QueryKey[]; }; const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { @@ -26,6 +28,7 @@ const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => { placeholder={props.placeholder ?? 'Créez un tag de suivi personnalisé'} queryKey="tags_suivi_perso" tagTableName="libre_tag" + additionalKeysToInvalidate={props.additionalKeysToInvalidate} optionsListe={data} refetchOptions={refetch} onChange={({ values, selectedValue }) => { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index d9dcb82722..d8a5e36b6d 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -8,6 +8,7 @@ import { useDeleteTag, useTagCreate, useTagUpdate } from '.'; type SelectTagsProps = Omit & { queryKey: QueryKey; + additionalKeysToInvalidate?: QueryKey[]; tagTableName: TableTag; optionsListe?: Tag[]; userCreatedOptionsIds?: number[]; @@ -24,6 +25,7 @@ type SelectTagsProps = Omit & { const SelectTags = ({ queryKey, + additionalKeysToInvalidate, tagTableName, optionsListe, userCreatedOptionsIds, @@ -89,6 +91,7 @@ const SelectTags = ({ const { data: updatedTag, mutate: updateTag } = useTagUpdate({ key: [queryKey, collectiviteId], tagTableName, + keysToInvalidate: additionalKeysToInvalidate, onSuccess: refetchOptions, }); @@ -100,25 +103,6 @@ const SelectTags = ({ }); }; - useEffect(() => { - if (updatedTag) { - const tag = { - collectiviteId: collectiviteId!, - nom: updatedTag.nom, - id: updatedTag.id, - }; - - const otherTags = getSelectedValues(props.values).filter( - (t) => t.id !== tag.id - ); - - props.onChange({ - values: [tag, ...otherTags], - selectedValue: tag, - }); - } - }, [updatedTag]); - // *** // Suppression d'un tag de la liste d'options // *** diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts index 29705303d2..2ad29c7c50 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts @@ -21,17 +21,11 @@ export const useTagUpdate = ({ return useMutation( async (tag: TagUpdate) => { - if (tag.id) { - const { data, error } = await supabaseClient + if (tag.id) + await supabaseClient .from(tagTableName) .update(objectToSnake(tag)) - .eq('id', tag.id) - .select() - .single(); - - if (error) throw error; - return data; - } + .eq('id', tag.id); }, { mutationKey: 'update_tag', @@ -54,7 +48,9 @@ export const useTagUpdate = ({ queryClient.setQueryData(key, context?.previousdata); } queryClient.invalidateQueries(key); - keysToInvalidate?.forEach((key) => queryClient.invalidateQueries(key)); + keysToInvalidate?.forEach((key) => { + queryClient.invalidateQueries(key); + }); }, onSuccess: () => onSuccess?.(), } From 51b9c8a1345a49e9e8d27328c530f5e9f40a6211 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:44:44 +0100 Subject: [PATCH 11/14] refactor: consolidate additionalKeysToInvalidate for fiche_action in ModaleActeurs to improve code maintainability --- .../FicheActionActeurs/ModaleActeurs.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx index a1065460e5..62097438a2 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionActeurs/ModaleActeurs.tsx @@ -37,6 +37,8 @@ const ModaleActeurs = ({ const collectivite = useCurrentCollectivite(); const collectiviteId = collectivite?.collectivite_id || null; + const ficheActionInvalidationKeys = [['fiche_action', fiche.id.toString()]]; + const handleSave = () => { if (!_.isEqual(fiche, editedFiche)) { updateFiche(editedFiche); @@ -61,9 +63,7 @@ const ModaleActeurs = ({ services, })) } - additionalKeysToInvalidate={[ - ['fiche_action', fiche.id.toString()], - ]} + additionalKeysToInvalidate={ficheActionInvalidationKeys} /> @@ -77,9 +77,7 @@ const ModaleActeurs = ({ structures, })) } - additionalKeysToInvalidate={[ - ['fiche_action', fiche.id.toString()], - ]} + additionalKeysToInvalidate={ficheActionInvalidationKeys} /> @@ -94,9 +92,7 @@ const ModaleActeurs = ({ referents: personnes, })) } - additionalKeysToInvalidate={[ - ['fiche_action', fiche.id.toString()], - ]} + additionalKeysToInvalidate={ficheActionInvalidationKeys} /> @@ -110,9 +106,7 @@ const ModaleActeurs = ({ partenaires, })) } - additionalKeysToInvalidate={[ - ['fiche_action', fiche.id.toString()], - ]} + additionalKeysToInvalidate={ficheActionInvalidationKeys} /> From b3d9c782543ef61e17781dc1ba78385d599e36c6 Mon Sep 17 00:00:00 2001 From: Elisabeth Fainstein <139369258+elisfainstein@users.noreply.github.com> Date: Wed, 15 Jan 2025 15:03:09 +0100 Subject: [PATCH 12/14] refactor: remove unused updatedTag variable --- .../src/ui/dropdownLists/tags/SelectTags.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index d8a5e36b6d..6b9799e544 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -88,7 +88,7 @@ const SelectTags = ({ // Mise à jour d'un tag de la liste d'options // *** - const { data: updatedTag, mutate: updateTag } = useTagUpdate({ + const { mutate: updateTag } = useTagUpdate({ key: [queryKey, collectiviteId], tagTableName, keysToInvalidate: additionalKeysToInvalidate, From 512dd561412b05ca8d638a747acac9ac6991fb76 Mon Sep 17 00:00:00 2001 From: Fred <98240+farnoux@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:11:16 +0100 Subject: [PATCH 13/14] Refetch personnes in select after update --- .../PersonnesDropdown/PersonnesDropdown.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx index 7cfbaf1b9e..b76c9492f6 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown.tsx @@ -29,7 +29,7 @@ type Props = Omit & { const PersonnesDropdown = (props: Props) => { const collectiviteId = useCollectiviteId(); - const { data: personneListe } = usePersonneListe(); + const { data: personneListe, refetch } = usePersonneListe(); const options: Option[] = personneListe ? personneListe.map((personne) => ({ @@ -50,16 +50,25 @@ const PersonnesDropdown = (props: Props) => { key: ['personnes', collectiviteId], tagTableName: 'personne_tag', keysToInvalidate: props.additionalKeysToInvalidate, + onSuccess: () => { + refetch(); + }, }); const { mutate: deleteTag } = useDeleteTag({ key: ['personnes', collectiviteId], tagTableName: 'personne_tag', + onSuccess: () => { + refetch(); + }, }); const { data: newTag, mutate: createTag } = useTagCreate({ key: ['personnes', collectiviteId], tagTableName: 'personne_tag', + onSuccess: () => { + refetch(); + }, }); const newTagId = newTag?.data?.[0].id; From e38078ee1495cbffb28e9eec4ba5a38e7997ddd9 Mon Sep 17 00:00:00 2001 From: Marc Rutkowski Date: Thu, 16 Jan 2025 14:13:43 +0100 Subject: [PATCH 14/14] =?UTF-8?q?D=C3=A9sactive=20la=20v=C3=A9rification?= =?UTF-8?q?=20du=20typage=20dans=20les=20tests=20ex=C3=A9cut=C3=A9s=20avec?= =?UTF-8?q?=20Deno?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 3f84268fbe..740ec40661 100644 --- a/Earthfile +++ b/Earthfile @@ -611,7 +611,7 @@ api-test: --env SUPABASE_URL=$API_URL \ --env SUPABASE_KEY=$SERVICE_ROLE_KEY \ --env SUPABASE_SERVICE_ROLE_KEY=$SERVICE_ROLE_KEY \ - api-test:latest test -A tests/$test/*.test.ts --location 'http://localhost' + api-test:latest test --no-check -A tests/$test/*.test.ts --location 'http://localhost' END api-crud-test: