From 24f2da9125fe841b1ce6edf88ea939334655b856 Mon Sep 17 00:00:00 2001 From: marlenetienne Date: Wed, 5 Mar 2025 17:58:43 +0100 Subject: [PATCH 1/2] fix: ANT-2905 - Study creation: project input should not appear inside modal --- .../common/modal/StudyCreationModal.tsx | 21 +++++++++++++------ .../home/components/StudyTableDisplay.tsx | 4 +++- .../projectDetails/ProjectDetails.tsx | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/components/common/modal/StudyCreationModal.tsx b/src/components/common/modal/StudyCreationModal.tsx index f428e4b..ee9bcd6 100644 --- a/src/components/common/modal/StudyCreationModal.tsx +++ b/src/components/common/modal/StudyCreationModal.tsx @@ -18,13 +18,19 @@ interface StudyCreationModalProps { onClose: () => void; study?: StudyDTO | null; setReloadStudies: React.Dispatch>; + projectInfoName?: string; } -const StudyCreationModal: React.FC = ({ onClose, study, setReloadStudies }) => { +const StudyCreationModal: React.FC = ({ + onClose, + study, + setReloadStudies, + projectInfoName, +}) => { const { t } = useTranslation(); const [studyName, setStudyName] = useState(''); const [horizon, setHorizon] = useState(''); - const [projectName, setProjectName] = useState(study?.project || ''); + const [projectName, setProjectName] = useState(study?.project || projectInfoName || ''); const [keywords, setKeywords] = useState(study?.keywords || []); const [trajectoryIds] = useState(study?.trajectoryIds || []); const [isFormValid, setIsFormValid] = useState(false); @@ -51,7 +57,8 @@ const StudyCreationModal: React.FC = ({ onClose, study, }; const validateForm = () => { - if (studyName && projectName && horizon && keywords.length > 0 && !errorMessage) { + //const isProjectValid = !study || projectName; + if (studyName && projectName && horizon && !errorMessage) { setIsFormValid(true); } else { setIsFormValid(false); @@ -107,9 +114,11 @@ const StudyCreationModal: React.FC = ({ onClose, study, minNbCharacters={3} /> -
- -
+ {study && ( +
+ +
+ )} diff --git a/src/pages/pegase/home/components/StudyTableDisplay.tsx b/src/pages/pegase/home/components/StudyTableDisplay.tsx index a7579e0..0235190 100644 --- a/src/pages/pegase/home/components/StudyTableDisplay.tsx +++ b/src/pages/pegase/home/components/StudyTableDisplay.tsx @@ -23,9 +23,10 @@ import StudyCreationModal from '@common/modal/StudyCreationModal'; interface StudyTableDisplayProps { searchStudy: string | undefined; projectId?: string; + projectInfoName?: string; } -const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) => { +const StudyTableDisplay = ({ searchStudy, projectId, projectInfoName }: StudyTableDisplayProps) => { const { t } = useTranslation(); const [rowSelection, setRowSelection] = useState({}); const [isHeaderHovered, setIsHeaderHovered] = useState(false); @@ -135,6 +136,7 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = onClose={toggleModal} study={selectedStudy} setReloadStudies={setReloadStudies} + projectInfoName={projectInfoName} /> )} diff --git a/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx b/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx index 5b4d4c3..9db8661 100644 --- a/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx +++ b/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx @@ -92,7 +92,7 @@ const ProjectDetails = () => { status={activeChip ? 'secondary' : 'primary'} /> - + ); }; From b0e3f1b0de619cae0262887b8d7e793fed528a05 Mon Sep 17 00:00:00 2001 From: marlenetienne Date: Wed, 5 Mar 2025 18:00:35 +0100 Subject: [PATCH 2/2] fix: remove console log --- src/components/common/modal/StudyCreationModal.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/common/modal/StudyCreationModal.tsx b/src/components/common/modal/StudyCreationModal.tsx index ee9bcd6..37137a8 100644 --- a/src/components/common/modal/StudyCreationModal.tsx +++ b/src/components/common/modal/StudyCreationModal.tsx @@ -57,8 +57,7 @@ const StudyCreationModal: React.FC = ({ }; const validateForm = () => { - //const isProjectValid = !study || projectName; - if (studyName && projectName && horizon && !errorMessage) { + if (studyName && projectName && horizon && keywords.length > 0 && !errorMessage) { setIsFormValid(true); } else { setIsFormValid(false);