Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 [fiche action] fix: afficher automatiquement le tag modifié quand on édite un tag #3522

Merged
merged 17 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5e81fd7
refactor: change link to panier
elisfainstein Dec 26, 2024
c729fb4
feat: trigger setEditFiche when a tag is edited (all tags except pers…
elisfainstein Jan 13, 2025
209154b
feat: add trigger when a tag is edited in ModaleActeurs and ModaleDes…
elisfainstein Jan 13, 2025
a07d149
refactor: remove onTagEdit handlers from dropdown components
elisfainstein Jan 14, 2025
b4fbb10
feat: update tag handling in SelectTags component to trigger onChange…
elisfainstein Jan 14, 2025
f9ebd35
refactor: remove 'Actions à Impact' navigation item from Header (make…
elisfainstein Jan 14, 2025
5bce6d5
refactor: remove updateFicheActionTagInList function and its imports
elisfainstein Jan 14, 2025
1f34107
refactor: remove useless constant
elisfainstein Jan 14, 2025
32ee808
refactor: simplify onChange handler for TagsSuiviPersoDropdown
elisfainstein Jan 14, 2025
0bb076e
refactor: add additionalKeysToInvalidate to support cache invalidatio…
elisfainstein Jan 15, 2025
a7765e4
Merge branch 'main' into TET-4192/fix-front-tag-refresh
elisfainstein Jan 15, 2025
51b9c8a
refactor: consolidate additionalKeysToInvalidate for fiche_action in …
elisfainstein Jan 15, 2025
b3d9c78
refactor: remove unused updatedTag variable
elisfainstein Jan 15, 2025
512dd56
Refetch personnes in select after update
farnoux Jan 15, 2025
e38078e
Désactive la vérification du typage dans les tests exécutés avec Deno
marc-rutkowski Jan 16, 2025
f41cdc8
Merge branch 'main' into TET-4192/fix-front-tag-refresh
elisfainstein Jan 16, 2025
5d52164
Merge branch 'main' into TET-4192/fix-front-tag-refresh
elisfainstein Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,13 @@
RUN earthly +api-test-build
FOR test IN $tests
RUN echo "Running tests for tests/$test'"
RUN docker run --rm \

Check failure on line 608 in Earthfile

View workflow job for this annotation

GitHub Actions / test-api

Error

The command RUN docker run --rm --name api_test_tet --network $network --env SUPABASE_URL=$API_URL --env SUPABASE_KEY=$SERVICE_ROLE_KEY --env SUPABASE_SERVICE_ROLE_KEY=$SERVICE_ROLE_KEY api-test:latest test --no-check -A tests/$test/*.test.ts --location 'http://localhost' did not complete successfully. Exit code 1
--name api_test_tet \
--network $network \
--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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -61,6 +63,7 @@ const ModaleActeurs = ({
services,
}))
}
additionalKeysToInvalidate={ficheActionInvalidationKeys}
/>
</Field>

Expand All @@ -74,6 +77,7 @@ const ModaleActeurs = ({
structures,
}))
}
additionalKeysToInvalidate={ficheActionInvalidationKeys}
/>
</Field>

Expand All @@ -88,6 +92,7 @@ const ModaleActeurs = ({
referents: personnes,
}))
}
additionalKeysToInvalidate={ficheActionInvalidationKeys}
/>
</Field>

Expand All @@ -101,6 +106,7 @@ const ModaleActeurs = ({
partenaires,
}))
}
additionalKeysToInvalidate={ficheActionInvalidationKeys}
/>
</Field>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ const ModaleDescription = ({ fiche, updateFiche }: ModaleDescriptionProps) => {
onChange={({ libresTag }) =>
setEditedFiche((prevState) => ({ ...prevState, libresTag }))
}
additionalKeysToInvalidate={[
['fiche_action', fiche.id.toString()],
]}
/>
</Field>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const ModalePilotes = ({
pilotes: personnes,
}))
}
additionalKeysToInvalidate={[
['fiche_action', fiche.id.toString()],
]}
/>
</Field>
</FormSectionGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,6 +16,7 @@ type PartenairesDropdownProps = Omit<
partenaires: Tag[];
selectedPartenaire: Tag;
}) => void;
additionalKeysToInvalidate?: QueryKey[];
};

const PartenairesDropdown = (props: PartenairesDropdownProps) => {
Expand All @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SelectMultipleProps, 'values' | 'onChange' | 'options'> & {
values?: string[];
Expand All @@ -21,13 +22,14 @@ type Props = Omit<SelectMultipleProps, 'values' | 'onChange' | 'options'> & {
}) => void;
disabledOptionsIds?: string[];
disableEdition?: boolean;
additionalKeysToInvalidate?: QueryKey[];
};

/** Sélecteur de personnes de la collectivité */
const PersonnesDropdown = (props: Props) => {
const collectiviteId = useCollectiviteId();

const { data: personneListe } = usePersonneListe();
const { data: personneListe, refetch } = usePersonneListe();

const options: Option[] = personneListe
? personneListe.map((personne) => ({
Expand All @@ -47,16 +49,26 @@ const PersonnesDropdown = (props: Props) => {
const { mutate: updateTag } = useTagUpdate({
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -16,6 +17,7 @@ type ServicesPilotesDropdownProps = Omit<
selectedService: Tag;
}) => void;
disabledOptionsIds?: number[];
additionalKeysToInvalidate?: QueryKey[];
};

const ServicesPilotesDropdown = (props: ServicesPilotesDropdownProps) => {
Expand All @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,6 +16,7 @@ type StructuresDropdownProps = Omit<
structures: Tag[];
selectedStructure: Tag;
}) => void;
additionalKeysToInvalidate?: QueryKey[];
};

const StructuresDropdown = (props: StructuresDropdownProps) => {
Expand All @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,6 +16,7 @@ type TagsSuiviPersoDropdownProps = Omit<
libresTag: Tag[];
selectedLibreTag: Tag;
}) => void;
additionalKeysToInvalidate?: QueryKey[];
};

const TagsSuiviPersoDropdown = (props: TagsSuiviPersoDropdownProps) => {
Expand All @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useDeleteTag, useTagCreate, useTagUpdate } from '.';

type SelectTagsProps = Omit<SelectMultipleProps, 'options' | 'onChange'> & {
queryKey: QueryKey;
additionalKeysToInvalidate?: QueryKey[];
tagTableName: TableTag;
optionsListe?: Tag[];
userCreatedOptionsIds?: number[];
Expand All @@ -24,6 +25,7 @@ type SelectTagsProps = Omit<SelectMultipleProps, 'options' | 'onChange'> & {

const SelectTags = ({
queryKey,
additionalKeysToInvalidate,
tagTableName,
optionsListe,
userCreatedOptionsIds,
Expand Down Expand Up @@ -89,6 +91,7 @@ const SelectTags = ({
const { mutate: updateTag } = useTagUpdate({
key: [queryKey, collectiviteId],
tagTableName,
keysToInvalidate: additionalKeysToInvalidate,
onSuccess: refetchOptions,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,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?.(),
}
Expand Down
Loading