From e542a4d7db885b76dd2382130169ba356fb70d92 Mon Sep 17 00:00:00 2001 From: vargastat <130074062+vargastat@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:52:21 +0100 Subject: [PATCH] Fix/ant 2722 v2 project details (#44) * feat: project details new order and add keywords * feat: create_study back in project details and Horizon in good place for study details --- .../common/modal/StudyCreationModal.tsx | 2 +- .../home/components/StudyTableDisplay.tsx | 34 +++++++++++++++---- .../projectDetails/ProjectDetails.tsx | 3 +- .../projectDetails/ProjectDetailsContent.tsx | 17 +++++++++- .../studyDetails/StudyDetailsContent.tsx | 8 ++--- src/shared/i18n/en.json | 9 +++-- src/shared/i18n/fr.json | 8 ++++- 7 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/components/common/modal/StudyCreationModal.tsx b/src/components/common/modal/StudyCreationModal.tsx index dc72ffd..fe01094 100644 --- a/src/components/common/modal/StudyCreationModal.tsx +++ b/src/components/common/modal/StudyCreationModal.tsx @@ -87,7 +87,7 @@ const StudyCreationModal: React.FC = ({ onClose, study, return ( - {study ? t('home.@duplicate_study') : t('home.@new_study')} + {study ? t('home.@duplicate_study') : t('project.@new_study')}
diff --git a/src/pages/pegase/home/components/StudyTableDisplay.tsx b/src/pages/pegase/home/components/StudyTableDisplay.tsx index b40b1ed..a1c33b2 100644 --- a/src/pages/pegase/home/components/StudyTableDisplay.tsx +++ b/src/pages/pegase/home/components/StudyTableDisplay.tsx @@ -16,6 +16,9 @@ import StdSimpleTable from '@/components/common/data/stdSimpleTable/StdSimpleTab import { RdsButton } from 'rte-design-system-react'; import { useStudyTableDisplay } from '@/hooks/useStudyTableDisplay'; import { useStudyNavigation } from '@/hooks/useStudyNavigation'; +import { useTranslation } from 'react-i18next'; +import { useNewStudyModal } from '@/hooks/useNewStudyModal'; +import StudyCreationModal from '@common/modal/StudyCreationModal'; interface StudyTableDisplayProps { searchStudy: string | undefined; @@ -23,13 +26,16 @@ interface StudyTableDisplayProps { } const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) => { + const { t } = useTranslation(); const [rowSelection, setRowSelection] = useState({}); const [isHeaderHovered, setIsHeaderHovered] = useState(false); + const [selectedStudy, setSelectedStudy] = useState(null); // Reload trigger for re-fetching data const [reloadStudies, setReloadStudies] = useState(false); const [sortBy, setSortBy] = useState<{ [key: string]: 'asc' | 'desc' }>({}); const [sortedColumn, setSortedColumn] = useState('status'); + const { isModalOpen, toggleModal } = useNewStudyModal(); const { navigateToStudy } = useStudyNavigation(); const { rows, count, intervalSize, currentPage, setPage } = useStudyTableDisplay({ searchTerm: searchStudy, @@ -56,6 +62,9 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = const isDeleteActive = selectedStatus === StudyStatus.ERROR || selectedStatus === StudyStatus.IN_PROGRESS; const handleDuplicate = () => { + const selectedStudy = rows[Number.parseInt(selectedRowId || '-1')]; + setSelectedStudy(selectedStudy); + toggleModal(); setReloadStudies(!reloadStudies); // Trigger reload after deleting }; @@ -102,24 +111,37 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) =
- {selectedRowId !== undefined && ( + {selectedRowId !== undefined ? ( <> - - + + + ) : ( + projectId !== '' && )}
+ {isModalOpen && ( + + )}
); }; - export default StudyTableDisplay; diff --git a/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx b/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx index 0385101..ae79763 100644 --- a/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx +++ b/src/pages/pegase/projects/projectDetails/ProjectDetails.tsx @@ -79,8 +79,9 @@ const ProjectDetails = () => {
diff --git a/src/pages/pegase/projects/projectDetails/ProjectDetailsContent.tsx b/src/pages/pegase/projects/projectDetails/ProjectDetailsContent.tsx index d972f06..4dec822 100644 --- a/src/pages/pegase/projects/projectDetails/ProjectDetailsContent.tsx +++ b/src/pages/pegase/projects/projectDetails/ProjectDetailsContent.tsx @@ -11,9 +11,15 @@ type ProjectDetailsContentProps = { description: string; creationDate: Date; createdBy: string; + keywords: string[]; }; -export const ProjectDetailsContent = ({ description, creationDate, createdBy }: ProjectDetailsContentProps) => { +export const ProjectDetailsContent = ({ + description, + creationDate, + createdBy, + keywords, +}: ProjectDetailsContentProps) => { const handleEditClick = () => { console.log('TO BE DONE'); }; @@ -25,8 +31,17 @@ export const ProjectDetailsContent = ({ description, creationDate, createdBy }:
+ {description} {formatDateToDDMMYYYY(creationDate)} {createdBy} + + {keywords.map((keyword, index) => ( + + {keyword} + {index < keywords.length - 1 ? ', ' : ''} + + ))} +
diff --git a/src/pages/pegase/studies/studyDetails/StudyDetailsContent.tsx b/src/pages/pegase/studies/studyDetails/StudyDetailsContent.tsx index 8b70d60..5e20c65 100644 --- a/src/pages/pegase/studies/studyDetails/StudyDetailsContent.tsx +++ b/src/pages/pegase/studies/studyDetails/StudyDetailsContent.tsx @@ -22,6 +22,10 @@ export const StudyDetailsContent = ({ study }: ProjectDetailsContentProps) => {
Study : {study.name}
+
+ + Horizon : {study.horizon} +
{formatDateToDDMMYYYY(study.creationDate)} @@ -30,10 +34,6 @@ export const StudyDetailsContent = ({ study }: ProjectDetailsContentProps) => { By : {study.createdBy}
-
- - Horizon : {study.horizon} -
diff --git a/src/shared/i18n/en.json b/src/shared/i18n/en.json index 2a52bbd..91ec6bb 100644 --- a/src/shared/i18n/en.json +++ b/src/shared/i18n/en.json @@ -38,7 +38,6 @@ "@project": "Project", "@my_studies": "My studies", "@my_projects": "My projects", - "@new_study": "Create a study", "@new_project": "Create a project", "@duplicate_study": "Duplicate a study" }, @@ -49,7 +48,8 @@ "@unpin": "Unpin", "@close": "Close", "@created": "Created", - "@by": "By" + "@by": "By", + "@new_study": "Create a study" }, "projectDetails": { "@buttonEdit": "Edit" @@ -60,5 +60,10 @@ "@keyword_minimum_error": "Keyword must be at least {{min}} characters", "@keyword_maximum_error": "Keyword must not exceed {{max}} characters", "@keyword_max_keys_errors": "Cannot add more than ${maxNbKey} keywords`" + }, + "study": { + "@open": "Open", + "@duplicate": "Duplicate", + "@delete": "Delete" } } diff --git a/src/shared/i18n/fr.json b/src/shared/i18n/fr.json index 315b91e..709572b 100644 --- a/src/shared/i18n/fr.json +++ b/src/shared/i18n/fr.json @@ -46,7 +46,8 @@ "@unpin": "Désépingler", "@close": "Fermer", "@created": "Crée le", - "@by": "Par" + "@by": "Par", + "@new_study": "Creer une étude" }, "projectDetails": { "@buttonEdit": "Editer" @@ -57,5 +58,10 @@ "@keyword_minimum_error": "Le mot-clé doit avoir à minumum {{min}} lettres", "@keyword_maximum_error": "Le mot-clé ne doit pas dépasser {{max}} lettres", "@keyword_max_keys_errors": "Il n'est pas possible d'ajouter plus que ${maxNbKey} mot-clés`" + }, + "study": { + "@open": "Ouvrir", + "@duplicate": "Dupliquer", + "@delete": "Effacer" } }