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

Fix/ant 2722 v2 project details #44

Merged
merged 2 commits into from
Feb 3, 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
2 changes: 1 addition & 1 deletion src/components/common/modal/StudyCreationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const StudyCreationModal: React.FC<StudyCreationModalProps> = ({ onClose, study,

return (
<RdsModal size="small">
<RdsModal.Title onClose={onClose}>{study ? t('home.@duplicate_study') : t('home.@new_study')}</RdsModal.Title>
<RdsModal.Title onClose={onClose}>{study ? t('home.@duplicate_study') : t('project.@new_study')}</RdsModal.Title>
<RdsModal.Content>
<div className="flex gap-4 self-stretch">
<div className="flex w-32 flex-col items-start justify-start">
Expand Down
34 changes: 28 additions & 6 deletions src/pages/pegase/home/components/StudyTableDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ 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;
projectId?: string;
}

const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) => {
const { t } = useTranslation();
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
const [isHeaderHovered, setIsHeaderHovered] = useState<boolean>(false);
const [selectedStudy, setSelectedStudy] = useState<StudyDTO | null>(null);
// Reload trigger for re-fetching data
const [reloadStudies, setReloadStudies] = useState<boolean>(false);
const [sortBy, setSortBy] = useState<{ [key: string]: 'asc' | 'desc' }>({});
const [sortedColumn, setSortedColumn] = useState<string | null>('status');

const { isModalOpen, toggleModal } = useNewStudyModal();
const { navigateToStudy } = useStudyNavigation();
const { rows, count, intervalSize, currentPage, setPage } = useStudyTableDisplay({
searchTerm: searchStudy,
Expand All @@ -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
};

Expand Down Expand Up @@ -102,24 +111,37 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) =
</div>
<div className="flex h-8 items-center justify-between bg-gray-200 px-4">
<div className="flex gap-2">
{selectedRowId !== undefined && (
{selectedRowId !== undefined ? (
<>
<RdsButton label="Open" onClick={handleRowClick} variant="outlined" />
<RdsButton label="Duplicate" onClick={handleDuplicate} variant="outlined" disabled={!isDuplicateActive} />
<RdsButton label={t('study.@open')} onClick={handleRowClick} variant="outlined" />
<RdsButton
label={t('study.@duplicate')}
onClick={handleDuplicate}
variant="outlined"
disabled={!isDuplicateActive}
/>
<RdsButton
label="Delete"
label={t('study.@delete')}
onClick={handleDeleteClick}
variant="outlined"
color="danger"
disabled={!isDeleteActive}
/>
</>
) : (
projectId !== '' && <RdsButton label={t('project.@new_study')} onClick={toggleModal} />
)}
</div>
<StudiesPagination count={count} intervalSize={intervalSize} current={currentPage} onChange={setPage} />
</div>
{isModalOpen && (
<StudyCreationModal
isOpen={isModalOpen}
onClose={toggleModal}
study={selectedStudy}
setReloadStudies={setReloadStudies}
/>
)}
</div>
);
};

export default StudyTableDisplay;
3 changes: 2 additions & 1 deletion src/pages/pegase/projects/projectDetails/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ const ProjectDetails = () => {
<div className="flex flex-col">
<ProjectDetailsContent
description={projectInfo.description}
createdBy={projectInfo.createdBy}
creationDate={projectInfo.creationDate}
createdBy={projectInfo.createdBy}
keywords={projectInfo.tags}
/>
</div>
<div className="flex gap-4 px-3 py-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand All @@ -25,8 +31,17 @@ export const ProjectDetailsContent = ({ description, creationDate, createdBy }:

<div className="flex items-center justify-between font-sans font-light text-gray-500">
<div className="flex items-center gap-3">
<span>{description}</span>
<span>{formatDateToDDMMYYYY(creationDate)}</span>
<span>{createdBy}</span>
<span>
{keywords.map((keyword, index) => (
<span key={index}>
{keyword}
{index < keywords.length - 1 ? ', ' : ''}
</span>
))}
</span>
</div>

<RdsIconButton icon={RdsIconId.Edit} size="small" onClick={handleEditClick} />
Expand Down
8 changes: 4 additions & 4 deletions src/pages/pegase/studies/studyDetails/StudyDetailsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const StudyDetailsContent = ({ study }: ProjectDetailsContentProps) => {
<div className="flex items-center gap-3">
<div className="flex flex-[1_0_0] items-center gap-6">
<div>Study : {study.name}</div>
<div className="flex items-center gap-2">
<StdIcon name={StdIconId.TimeLine} color="secondary" />
Horizon : {study.horizon}
</div>
<div className="flex items-center gap-2">
<RdsIcon name={RdsIconId.History} color="secondary" />
{formatDateToDDMMYYYY(study.creationDate)}
Expand All @@ -30,10 +34,6 @@ export const StudyDetailsContent = ({ study }: ProjectDetailsContentProps) => {
<RdsIcon name={RdsIconId.Person} color="secondary" />
By : {study.createdBy}
</div>
<div className="flex items-center gap-2">
<StdIcon name={StdIconId.TimeLine} color="secondary" />
Horizon : {study.horizon}
</div>
<div className="flex h-3 w-32">
<RdsTagList id={`${study.id}-tag-list`} tags={study.keywords} />
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/shared/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -49,7 +48,8 @@
"@unpin": "Unpin",
"@close": "Close",
"@created": "Created",
"@by": "By"
"@by": "By",
"@new_study": "Create a study"
},
"projectDetails": {
"@buttonEdit": "Edit"
Expand All @@ -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"
}
}
8 changes: 7 additions & 1 deletion src/shared/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
}
Loading