Skip to content

Commit

Permalink
Merge branch 'feature/progress-update-flow-modal' into test/progress-…
Browse files Browse the repository at this point in the history
…update-flow-modal
  • Loading branch information
Achintya-Chatterjee authored Dec 4, 2024
2 parents bd2f228 + 1c29370 commit a6e781b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 23 deletions.
8 changes: 5 additions & 3 deletions src/components/taskDetails/TaskDetailsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ export const TaskDetailsSection: React.FC<TaskDetailsSectionProps> = ({
taskDetailsData,
}) => {
const router = useRouter();

const { dev } = router.query;
const isDevMode = dev === 'true';

return (
<div className={styles['sub_details_grid_container']}>
<Details detailType={'Type'} value={type} />
<Details detailType={'Priority'} value={priority} />

{isEditing ? (
<TaskDropDown
onChange={handleTaskStatusUpdate}
Expand All @@ -51,12 +52,13 @@ export const TaskDetailsSection: React.FC<TaskDetailsSectionProps> = ({
/>
)}
<Details detailType={'Link'} value={link} />
{isDevMode ? null : (
<div className={styles.progressWrapper}>
<ProgressContainer
content={taskDetailsData}
readOnly={true}
key={percentCompleted}
/>
)}
</div>
</div>
);
};
2 changes: 1 addition & 1 deletion src/components/taskDetails/TaskUpdateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function TaskUpdateModal({
</section>
<div className={styles.hr} />
<ProgressContainer
isDev={isDev}
content={taskDetailsData}
key={editedTaskDetails?.percentCompleted}
readOnly={false}
/>
</div>
</Modal>
Expand Down
4 changes: 1 addition & 3 deletions src/components/tasks/card/card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@

@media screen and (max-width: 1128px) {
.progressContainerUpdated {
flex-direction: column;
justify-content: start;
align-items: start;
width: 100%;
gap: 1rem;
}
}
Expand Down
30 changes: 19 additions & 11 deletions src/components/tasks/card/progressContainer/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,44 @@ import ProgressSlider from './ProgressSlider';
import ProgressIndicator from './ProgressIndicator';
import styles from '@/components/tasks/card/card.module.scss';

const Progressbar: FC<ProgressBarProps> = ({
interface ExtendedProgressBarProps extends ProgressBarProps {
readOnly?: boolean;
}

const Progressbar: FC<ExtendedProgressBarProps> = ({
progress,
progressValue,
handleProgressChange,
debounceSlider,
startedOn,
endsOn,
isLoading,
readOnly = false,
}) => {
if (progress) {
// If readOnly or not in progress mode, show the indicator
if (readOnly || !progress) {
return (
<>
<ProgressSlider
value={progressValue}
debounceSlider={debounceSlider}
handleProgressChange={handleProgressChange}
isLoading={isLoading}
<ProgressIndicator
percentCompleted={progressValue}
startedOn={startedOn}
endsOn={endsOn}
/>
<div className={styles.progressPercentageCompleted}>
{progressValue}%
</div>
</>
);
}

// Show slider when in edit mode
return (
<>
<ProgressIndicator
percentCompleted={progressValue}
startedOn={startedOn}
endsOn={endsOn}
<ProgressSlider
value={progressValue}
debounceSlider={debounceSlider}
handleProgressChange={handleProgressChange}
isLoading={isLoading}
/>
<div className={styles.progressPercentageCompleted}>
{progressValue}%
Expand Down
17 changes: 13 additions & 4 deletions src/components/tasks/card/progressContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import { ERROR_MESSAGE, PROGRESS_SUCCESSFUL } from '@/constants/constants';
import styles from '@/components/tasks/card/card.module.scss';
import { ProgressContainerProps } from '@/interfaces/task.type';

const ProgressContainer: FC<ProgressContainerProps> = ({ content }) => {
const ProgressContainer: FC<ProgressContainerProps> = ({
content,
readOnly = false,
}) => {
const router = useRouter();
const { dev } = router.query;
const isDev = dev === 'true';

const [isProgressMade, setIsProgressMade] = useState<boolean>(false);
const [progressValue, setProgressValue] = useState<number>(
Expand Down Expand Up @@ -89,9 +93,12 @@ const ProgressContainer: FC<ProgressContainerProps> = ({ content }) => {
};

const showUpdateButton = () => {
// Only show update button in modal (not readOnly) and in dev mode
if (
content.assignee === userData?.username ||
!!userData?.roles.super_user
!readOnly &&
isDev &&
(content.assignee === userData?.username ||
!!userData?.roles.super_user)
) {
return (
<ProgressText
Expand All @@ -100,20 +107,22 @@ const ProgressContainer: FC<ProgressContainerProps> = ({ content }) => {
/>
);
}
return null;
};

return (
<>
<div className={styles.progressContainerUpdated}>
<Progressbar
progress={isProgressMade}
progress={!readOnly && isProgressMade}
progressValue={progressValue}
percentCompleted={content.percentCompleted}
handleProgressChange={handleProgressChange}
debounceSlider={debounceSlider}
startedOn={content.startedOn}
endsOn={String(content.endsOn)}
isLoading={checkingLoading}
readOnly={readOnly}
/>
{showUpdateButton()}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/task.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export type CardProps = {

export type ProgressContainerProps = {
content: task;
isDev?: boolean;
readOnly: boolean;
};

export default task;
Expand Down

0 comments on commit a6e781b

Please sign in to comment.