From c1dd839937803f5f887c4e227e92f6c202f1092a Mon Sep 17 00:00:00 2001 From: AnujChhikara Date: Fri, 27 Dec 2024 09:48:25 +0530 Subject: [PATCH] refactor progress update card presentation --- .../ProgressUpdateCard.test.tsx | 2 +- .../ProgressUpdateCardOverview.tsx | 92 +++++++++++++++ .../ProgressUpdateCardPresentation.tsx | 105 ++---------------- .../latest-progress-update-card.module.scss | 4 +- .../progress-update-card.module.scss | 2 +- .../progressUpdateCard.types.ts | 10 ++ 6 files changed, 117 insertions(+), 98 deletions(-) create mode 100644 src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardOverview.tsx diff --git a/__tests__/Unit/Components/Tasks/ProgressUpdateCard/ProgressUpdateCard.test.tsx b/__tests__/Unit/Components/Tasks/ProgressUpdateCard/ProgressUpdateCard.test.tsx index 2ec000fcd..5caad7ad8 100644 --- a/__tests__/Unit/Components/Tasks/ProgressUpdateCard/ProgressUpdateCard.test.tsx +++ b/__tests__/Unit/Components/Tasks/ProgressUpdateCard/ProgressUpdateCard.test.tsx @@ -89,7 +89,7 @@ describe('ProgressUpdateCard Component', () => { ); const readMoreButton = screen.getByTestId( - 'progress-update-card-read-more-completed' + 'progress-update-read-more-toggle-button' ); expect(readMoreButton).toBeInTheDocument(); expect(readMoreButton).toHaveTextContent('More'); diff --git a/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardOverview.tsx b/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardOverview.tsx new file mode 100644 index 000000000..72c252814 --- /dev/null +++ b/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardOverview.tsx @@ -0,0 +1,92 @@ +import React from 'react'; +import { FaAngleRight, FaRegClock } from 'react-icons/fa6'; +import Tooltip from '@/components/common/Tooltip/Tooltip'; +import styles from './progress-update-card.module.scss'; +import { USER_MANAGEMENT_URL } from '@/constants/url'; +import { ProgressUpdateCardOverviewProps } from './progressUpdateCard.types'; +import { UserAvatar } from '@/components/common/UserAvatar/UserAvatar'; + +export default function ProgressUpdateCardOverview({ + titleToShow, + dateInAgoFormat, + username, + userProfileImageUrl, + tooltipString, + isDevMode, + isExpanded, +}: ProgressUpdateCardOverviewProps) { + return ( +
+

+ {titleToShow} +

+
+ + event.stopPropagation()} + data-testid="progress-update-card-date" + > + + + {dateInAgoFormat} + + + + + {isDevMode && + (username === '' ? ( + + ) : ( + + event.stopPropagation()} + > + + + + ))} + + +
+
+ ); +} diff --git a/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardPresentation.tsx b/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardPresentation.tsx index ed56f7892..dcc468dfe 100644 --- a/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardPresentation.tsx +++ b/src/components/taskDetails/ProgressUpdateCard/ProgressUpdateCardPresentation.tsx @@ -1,14 +1,11 @@ import React from 'react'; import { useRouter } from 'next/router'; -import { FaAngleRight, FaRegClock } from 'react-icons/fa6'; -import Tooltip from '@/components/common/Tooltip/Tooltip'; import styles from './progress-update-card.module.scss'; -import { USER_MANAGEMENT_URL } from '@/constants/url'; import { ProgressUpdateCardPresentationProps, ProgressUpdateDataToShow, } from './progressUpdateCard.types'; -import { UserAvatar } from '@/components/common/UserAvatar/UserAvatar'; +import ProgressUpdateCardOverview from './ProgressUpdateCardOverview'; export default function ProgressUpdateCardPresentation({ titleToShow, @@ -22,7 +19,6 @@ export default function ProgressUpdateCardPresentation({ isExpanded, }: ProgressUpdateCardPresentationProps) { const router = useRouter(); - console.log(isExpanded); const isDevMode = router.query.dev === 'true'; const progressInfoMapping = dataToShowState.map( (datum: ProgressUpdateDataToShow) => ( @@ -45,7 +41,7 @@ export default function ProgressUpdateCardPresentation({ className={ styles['progress-update-card__more-less-button'] } - data-testid="progress-update-card-read-more-completed" + data-testid="progress-update-read-more-toggle-button" > {datum.isReadMoreEnabled ? 'Less' : 'More'} @@ -64,94 +60,15 @@ export default function ProgressUpdateCardPresentation({ data-testid="progress-update-card-container" onClick={onCardClick} > -
-

- {titleToShow} -

-
- - event.stopPropagation()} - data-testid="progress-update-card-date" - > - - - {dateInAgoFormat} - - - - - {isDevMode && - (username === '' ? ( - - ) : ( - - - event.stopPropagation() - } - > - - - - ))} - - -
-
+