Skip to content

Commit

Permalink
simplify logic on enabling button
Browse files Browse the repository at this point in the history
  • Loading branch information
taraepp committed Oct 25, 2024
1 parent 409a850 commit 68cedfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ export const ProjectStagesTable: FC<ProjectStagesTableProps> = ({ projectStages
}
if (record.project_stage === "IRT") {
let buttonLabel: string;
let disableButton = Boolean(record.stage_status);
let enableButton = Boolean(record.stage_status);
if (!record.stage_status) {
buttonLabel = "Start";
disableButton = !isProjectSummarySubmitted;
enableButton = isProjectSummarySubmitted;
} else if (record.stage_status === "APV") {
buttonLabel = "View";
} else {
Expand All @@ -107,18 +107,18 @@ export const ProjectStagesTable: FC<ProjectStagesTableProps> = ({ projectStages
<Button
className="full-mobile margin-small"
onClick={() => record?.navigate_forward()}
disabled={disableButton}
disabled={!enableButton}
>
{buttonLabel}
</Button>
);
}
if (record.project_stage === "Application") {
let buttonLabel: string;
let disableButton = Boolean(record.stage_status);
let enableButton = Boolean(record.stage_status);
if (!record.stage_status) {
buttonLabel = "Start";
disableButton = !isProjectSummarySubmitted;
enableButton = isProjectSummarySubmitted;
} else if (["SUB", "UNR", "APV"].includes(record.stage_status)) {
buttonLabel = "View";
} else {
Expand All @@ -129,7 +129,7 @@ export const ProjectStagesTable: FC<ProjectStagesTableProps> = ({ projectStages
<Button
className="full-mobile margin-small"
onClick={() => record?.navigate_forward()}
disabled={disableButton}
disabled={!enableButton}
>
{buttonLabel}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ exports[`ProjectOverviewTab renders properly 1`] = `
>
<button
class="ant-btn ant-btn-default full-mobile margin-small"
disabled=""
type="button"
>
<span>
Expand Down

0 comments on commit 68cedfa

Please sign in to comment.