Skip to content

Commit

Permalink
FA : fix le reset des champs de la fiche après la mise à jour des obj…
Browse files Browse the repository at this point in the history
…ectifs
  • Loading branch information
cparthur committed Sep 12, 2024
1 parent 8e3276b commit 7b6748b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,33 @@ const IndicateursHeader = ({
isTextTruncated: isObjectifsTruncated,
} = getTruncatedText(objectifs, 1000);

const [isModalOpen, setIsModalOpen] = useState(false);

return (
<>
{/* Titre et bouton d'édition */}
<div className="flex justify-between">
<h5 className="text-primary-8 mb-0">Indicateurs de suivi</h5>
{!isReadonly && (
<ModaleIndicateursHeader fiche={fiche} updateFiche={updateFiche} />
<>
<Button
title="Modifier les informations"
icon="edit-line"
size="xs"
variant="grey"
onClick={() => setIsModalOpen(true)}
/>
{isModalOpen && (
<ModaleIndicateursHeader
fiche={fiche}
updateFiche={updateFiche}
openState={{
isOpen: isModalOpen,
setIsOpen: setIsModalOpen,
}}
/>
)}
</>
)}
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {useState} from 'react';
import _ from 'lodash';
import {
Button,
Field,
FormSectionGrid,
Modal,
Expand All @@ -11,17 +10,20 @@ import {
import {FicheAction} from '../data/types';
import EffetsAttendusDropdown from 'ui/dropdownLists/ficheAction/EffetsAttendusDropdown/EffetsAttendusDropdown';
import {getMaxLengthMessage} from '../utils';
import {OpenState} from '@tet/ui/dist/utils/types';

const OBJECTIFS_MAX_LENGTH = 10000;

type ModaleIndicateursHeaderProps = {
fiche: FicheAction;
updateFiche: (fiche: FicheAction) => void;
openState: OpenState;
};

const ModaleIndicateursHeader = ({
fiche,
updateFiche,
openState,
}: ModaleIndicateursHeaderProps) => {
const [editedFiche, setEditedFiche] = useState(fiche);

Expand All @@ -35,6 +37,7 @@ const ModaleIndicateursHeader = ({
<Modal
title="Indicateurs de suivi"
size="lg"
openState={openState}
render={({descriptionId}) => (
<FormSectionGrid formSectionId={descriptionId}>
{/* Objectifs */}
Expand Down Expand Up @@ -90,14 +93,7 @@ const ModaleIndicateursHeader = ({
}}
/>
)}
>
<Button
title="Modifier les informations"
icon="edit-line"
size="xs"
variant="grey"
/>
</Modal>
/>
);
};

Expand Down

0 comments on commit 7b6748b

Please sign in to comment.