-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Onglet fiches actions liées sur la page indicateur
- Loading branch information
Showing
6 changed files
with
206 additions
and
72 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...ritoiresentransitions.react/src/app/pages/collectivite/Indicateurs/detail/FichesLiees.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Button, EmptyCard } from '@/ui'; | ||
import { useState } from 'react'; | ||
import { objectToSnake } from 'ts-case-convert'; | ||
import FichePicto from '../../PlansActions/FicheAction/FichesLiees/FichePicto'; | ||
import ModaleFichesLiees from '../../PlansActions/FicheAction/FichesLiees/ModaleFichesLiees'; | ||
import FichesActionListe from '../../PlansActions/ToutesLesFichesAction/FichesActionListe'; | ||
import { | ||
useFichesActionLiees, | ||
useUpdateFichesActionLiees, | ||
} from '../Indicateur/useFichesActionLiees'; | ||
import { TIndicateurDefinition } from '../types'; | ||
|
||
type Props = { | ||
definition: TIndicateurDefinition; | ||
isReadonly: boolean; | ||
}; | ||
|
||
const FichesLiees = ({ definition, isReadonly }: Props) => { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
||
const { data: fiches } = useFichesActionLiees(definition); | ||
const fichesLiees = (fiches ? objectToSnake(fiches) : []).map((f) => f.id); | ||
|
||
const { mutate: updateFichesActionLiees } = | ||
useUpdateFichesActionLiees(definition); | ||
|
||
const isEmpty = fiches.length === 0; | ||
|
||
return ( | ||
<> | ||
{isEmpty ? ( | ||
<EmptyCard | ||
picto={(props) => <FichePicto {...props} />} | ||
title="Aucune fiche action de vos plans d'actions n'est liée !" | ||
isReadonly={isReadonly} | ||
actions={[ | ||
{ | ||
children: 'Lier une fiche action', | ||
icon: 'link', | ||
onClick: () => setIsModalOpen(true), | ||
}, | ||
]} | ||
size="xs" | ||
/> | ||
) : ( | ||
<div> | ||
<div className="flex justify-between items-center flex-wrap mb-5"> | ||
<h6 className="text-lg mb-0">Fiches des plans liées</h6> | ||
{!isReadonly && ( | ||
<Button | ||
icon="link" | ||
size="xs" | ||
className="w-fit" | ||
onClick={() => setIsModalOpen(true)} | ||
> | ||
Lier une fiche action | ||
</Button> | ||
)} | ||
</div> | ||
<FichesActionListe | ||
filtres={{ ficheActionIds: fichesLiees }} | ||
sortSettings={{ | ||
defaultSort: 'titre', | ||
}} | ||
isReadOnly={isReadonly} | ||
enableGroupedActions | ||
containeClassName="bg-white" | ||
/> | ||
</div> | ||
)} | ||
|
||
{isModalOpen && ( | ||
<ModaleFichesLiees | ||
isOpen={isModalOpen && !isReadonly} | ||
setIsOpen={setIsModalOpen} | ||
currentFicheId={null} | ||
linkedFicheIds={fichesLiees} | ||
updateLinkedFicheIds={updateFichesActionLiees} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default FichesLiees; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 76 additions & 47 deletions
123
...react/src/app/pages/collectivite/PlansActions/FicheAction/Carte/FicheActionFooterInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.