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

Tet 4038/referentiels new back #3612

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ActionStatutBadge from '@/app/referentiels/actions/action-statut.badge';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut/action-statut.badge';

export const PrecedenteActionStatutDetaille = ({
avancementDetaille,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
NouvelleActionStatutDetaille,
PrecedenteActionStatutDetaille,
} from '@/app/app/pages/collectivite/Historique/actionStatut/ActionStatutDetaillee';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut.badge';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut/action-statut.badge';
import { THistoriqueItemProps } from '../types';
import { getItemActionProps } from './getItemActionProps';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ type Props = {
const ActionsLiees = ({ actionsIds }: Props) => {
const isEmpty = actionsIds.length === 0;

return isEmpty ? (
<EmptyCard
picto={(props) => <ActionPicto {...props} />}
title="Aucune action des référentiels n'est liée !"
size="xs"
/>
) : (
if (isEmpty) {
return (
<EmptyCard
picto={(props) => <ActionPicto {...props} />}
title="Aucune action des référentiels n'est liée !"
size="xs"
/>
);
}

return (
<div className="bg-white p-10 border border-grey-3 rounded-xl">
<div className="w-full border-b border-primary-3 mb-6">
<h6 className="text-lg h-[2.125rem] mb-5">
Actions des référentiels liées
</h6>
</div>
<ActionsLieesListe
actionsIds={actionsIds}
actionIds={actionsIds}
className="sm:grid-cols-2 md:grid-cols-3"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { useGetEtapes } from '@/app/app/pages/collectivite/PlansActions/FicheAct
import ExportPDFButton from '@/app/ui/export-pdf/ExportPDFButton';
import { createElement, useEffect, useState } from 'react';
import { useIndicateurDefinitions } from '../../Indicateurs/Indicateur/useIndicateurDefinition';
import { useActionListe } from '../FicheAction/data/options/useActionListe';
import { useAnnexesFicheActionInfos } from '../FicheAction/data/useAnnexesFicheActionInfos';
import { useFicheActionNotesSuivi } from '../FicheAction/data/useFicheActionNotesSuivi';
import { useFichesActionLiees } from '../FicheAction/data/useFichesActionLiees';
import { useFicheActionChemins } from '../PlanAction/data/usePlanActionChemin';
import FicheActionPdf from './FicheActionPdf/FicheActionPdf';
import { useListActionsWithStatuts } from '@/app/referentiels/actions/use-list-actions';

type FicheActionPdfContentProps = {
fiche: FicheAction;
Expand All @@ -29,8 +29,10 @@ export const FicheActionPdfContent = ({
const { data: fichesLiees, isLoading: isLoadingFichesLiees } =
useFichesActionLiees(fiche.id);

const { data: actionListe, isLoading: isLoadignActionsListe } =
useActionListe();
const { data: actionsLiees, isLoading: isLoadignActionsListe } =
useListActionsWithStatuts({
actionIds: fiche?.actions?.map((action) => action.id) ?? [],
});

const { data: annexes, isLoading: isLoadingAnnexes } =
useAnnexesFicheActionInfos(fiche.id);
Expand All @@ -53,12 +55,6 @@ export const FicheActionPdfContent = ({

useEffect(() => {
if (!isLoading) {
const { actions } = fiche;
const actionsIds = (actions ?? []).map((action) => action.id);
const actionsLiees = (actionListe ?? []).filter((action) =>
actionsIds.some((id) => id === action.action_id)
);

generateContent(
createElement(FicheActionPdf, {
fiche,
Expand All @@ -68,7 +64,7 @@ export const FicheActionPdfContent = ({
indicateursListe,
etapes,
fichesLiees,
actionsLiees,
actionsLiees: actionsLiees ?? [],
annexes,
notesSuivi,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { referentielToName } from '@/app/app/labels';
import { getActionStatut } from '@/app/referentiels/utils';
import { TActionStatutsRow } from '@/app/types/alias';
import { ActionWithStatut } from '@/app/referentiels/actions/use-list-actions';
import {
BadgeStatutAction,
Card,
Paragraph,
Stack,
Title,
} from '@/app/ui/export-pdf/components';
import { objectToCamel } from 'ts-case-convert';

type ActionLieeCardProps = {
action: TActionStatutsRow;
action: ActionWithStatut;
};

const ActionLieeCard = ({ action }: ActionLieeCardProps) => {
const { identifiant, nom, referentiel } = action;
const statut = getActionStatut(objectToCamel(action));

return (
<Card wrap={false} gap={1.5} className="w-[32%] p-3">
{/* Avancement */}
<BadgeStatutAction statut={statut} size="sm" />
<BadgeStatutAction statut={action.statut} size="sm" />

<Stack gap={1}>
{/* Référentiel associé */}
Expand All @@ -39,7 +36,7 @@ const ActionLieeCard = ({ action }: ActionLieeCardProps) => {
};

type ActionsLieesProps = {
actionsLiees: TActionStatutsRow[];
actionsLiees: ActionWithStatut[];
};

const ActionsLiees = ({ actionsLiees }: ActionsLieesProps) => {
Expand All @@ -53,7 +50,7 @@ const ActionsLiees = ({ actionsLiees }: ActionsLieesProps) => {
{actionsLiees.length > 0 && (
<Stack gap={3} direction="row" className="flex-wrap">
{actionsLiees.map((action) => (
<ActionLieeCard key={action.action_id} action={action} />
<ActionLieeCard key={action.actionId} action={action} />
))}
</Stack>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FicheAction, FicheActionNote, FicheResume } from '@/api/plan-actions';
import { TActionStatutsRow, TAxeRow } from '@/app/types/alias';
import { TAxeRow } from '@/app/types/alias';
import { Divider, Stack, Title } from '@/app/ui/export-pdf/components';
import { AnnexeInfo } from '../../FicheAction/data/useAnnexesFicheActionInfos';

Expand All @@ -19,6 +19,7 @@ import Notes from './Notes';
import NotesDeSuivi from './NotesDeSuivi';
import Pilotes from './Pilotes';
import Planning from './Planning';
import { ActionWithStatut } from '@/app/referentiels/actions/use-list-actions';

export type FicheActionPdfProps = {
fiche: FicheAction;
Expand All @@ -29,7 +30,7 @@ export type FicheActionPdfExtendedProps = FicheActionPdfProps & {
indicateursListe: TIndicateurDefinition[] | undefined | null;
etapes?: RouterOutput['plans']['fiches']['etapes']['list'];
fichesLiees: FicheResume[];
actionsLiees: TActionStatutsRow[];
actionsLiees: ActionWithStatut[];
annexes: AnnexeInfo[] | undefined;
notesSuivi: FicheActionNote[] | undefined;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import ActionLinkedCard from '@/app/referentiels/actions/action.linked-card';
import { useListActionsWithStatuts } from '@/app/referentiels/actions/use-list-actions';
import SpinnerLoader from '@/app/ui/shared/SpinnerLoader';
import classNames from 'classnames';
import { useEffect } from 'react';
import ActionLinkedCard from '../../../../../../referentiels/actions/action.linked-card';
import { useActionListe } from '../data/options/useActionListe';

type ActionsLieesListeProps = {
isReadonly?: boolean;
actionsIds: string[];
actionIds: string[];
className?: string;
onLoad?: (isLoading: boolean) => void;
onUnlink?: (actionId: string) => void;
};

const ActionsLieesListe = ({
isReadonly,
actionsIds,
actionIds,
className,
onLoad,
onUnlink,
}: ActionsLieesListeProps) => {
const { data: actionsLiees, isLoading } = useActionListe(actionsIds);
const { data: actionsLiees, isLoading } = useListActionsWithStatuts({
actionIds,
});

useEffect(() => onLoad?.(isLoading), [isLoading]);

Expand All @@ -40,10 +42,10 @@ const ActionsLieesListe = ({
>
{actionsLiees.map((action) => (
<ActionLinkedCard
key={action.action_id}
key={action.actionId}
isReadonly={isReadonly}
action={action}
onUnlink={onUnlink ? () => onUnlink(action.action_id) : undefined}
onUnlink={onUnlink ? () => onUnlink(action.actionId) : undefined}
openInNewTab
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ActionsLieesTab = ({
{/* Liste des actions des référentiels liées */}
<ActionsLieesListe
isReadonly={isReadonly}
actionsIds={actions?.map((action) => action.id)}
actionIds={actions?.map((action) => action.id)}
className="sm:grid-cols-2 md:grid-cols-3"
onLoad={setIsLoading}
onUnlink={(actionsLieeId) =>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { cloneDeep, pick } from 'es-toolkit';

import { useCollectiviteModuleUpsert } from '@/app/app/pages/collectivite/TableauDeBord/Collectivite/useCollectiviteModuleUpsert';
import { useCurrentCollectivite } from '@/app/core-logic/hooks/useCurrentCollectivite';
import { CreateModuleFicheActionCountByType } from '@/backend/collectivites/tableau-de-bord/module-fiche-action-count-by.schema';
import { CreateModuleFicheActionCountByType } from '@/domain/collectivites';
import {
CountByPropertyEnumType,
ficheActionForCountBySchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SelectActionStatut } from '@/app/referentiels/actions/action-statut.select';
import { useEditActionStatutIsDisabled } from '@/app/referentiels/use-action-statut';
import { SelectActionStatut } from '@/app/referentiels/actions/action-statut/action-statut.select';
import { useEditActionStatutIsDisabled } from '@/app/referentiels/actions/action-statut/use-action-statut';
import { statutAvancementEnumSchema } from '@/domain/referentiels';
import { useCallback } from 'react';
import { TCellProps } from './DetailTacheTable';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ActionStatutBadge from '@/app/referentiels/actions/action-statut.badge';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut/action-statut.badge';
import {
MultiSelectFilter,
MultiSelectFilterTitle,
} from '@/app/ui/shared/select/MultiSelectFilter';

import { DEFAULT_OPTIONS } from '@/app/referentiels/actions/action-statut.select';
import { DEFAULT_OPTIONS } from '@/app/referentiels/actions/action-statut/action-statut.select';
import { ITEM_ALL } from '@/app/ui/shared/filters/commons';
import { StatutAvancementIncludingNonConcerne } from '@/domain/referentiels';
import { TFiltreProps } from './filters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { intersection } from 'es-toolkit';
import { useMutation, useQuery, useQueryClient } from 'react-query';
import { TableOptions } from 'react-table';
import { useSaveActionStatut } from '../actions/action-statut/use-action-statut';
import {
actionNewToDeprecated,
ProgressionRow,
Expand All @@ -19,7 +20,6 @@ import {
NEW_useTable,
useReferentiel,
} from '../ReferentielTable/useReferentiel';
import { useSaveActionStatut } from '../use-action-statut';
import { useSnapshotFlagEnabled } from '../use-snapshot';
import { initialFilters, nameToShortNames, TFilters } from './filters';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { omit } from 'es-toolkit';
import { objectToCamel, objectToSnake } from 'ts-case-convert';
import { useCollectiviteId } from '../collectivites/collectivite-context';
import { useCurrentCollectivite } from '../core-logic/hooks/useCurrentCollectivite';
import { useActionScore } from './DEPRECATED_score-hooks';
import { useCollectiviteId } from '../../../collectivites/collectivite-context';
import { useCurrentCollectivite } from '../../../core-logic/hooks/useCurrentCollectivite';
import { useActionScore } from '../../DEPRECATED_score-hooks';
import {
useScore,
useSnapshotComputeAndUpdate,
useSnapshotFlagEnabled,
} from './use-snapshot';
} from '../../use-snapshot';

/**
* Charge le statut d'une action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { referentielToName } from '@/app/app/labels';
import { makeReferentielTacheUrl } from '@/app/app/paths';
import { useCollectiviteId } from '@/app/core-logic/hooks/params';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut.badge';
import { getActionStatut } from '@/app/referentiels/utils';
import { TActionStatutsRow } from '@/app/types/alias';
import { useCollectiviteId } from '@/app/collectivites/collectivite-context';
import ActionStatutBadge from '@/app/referentiels/actions/action-statut/action-statut.badge';
import { ActionWithStatut } from '@/app/referentiels/actions/use-list-actions';
import { Button, Card } from '@/ui';
import { objectToCamel } from 'ts-case-convert';

type ActionCardProps = {
isReadonly?: boolean;
action: TActionStatutsRow;
action: ActionWithStatut;
openInNewTab?: boolean;
onUnlink?: () => void;
};
Expand All @@ -20,9 +18,8 @@ const ActionLinkedCard = ({
openInNewTab = false,
onUnlink,
}: ActionCardProps) => {
const collectiviteId = useCollectiviteId()!;
const { action_id: actionId, identifiant, nom, referentiel } = action;
const statut = getActionStatut(objectToCamel(action));
const collectiviteId = useCollectiviteId();
const { actionId, identifiant, nom, referentiel, statut } = action;

const link = makeReferentielTacheUrl({
collectiviteId,
Expand All @@ -46,7 +43,7 @@ const ActionLinkedCard = ({

<Card
dataTest="ActionCarte"
id={`action-${action.action_id}`}
id={`action-${actionId}`}
className="h-full px-4 py-[1.125rem] !gap-3 text-grey-8 hover:border-primary-3 hover:!bg-primary-1 !shadow-none transition"
href={link}
external={openInNewTab}
Expand Down
Loading