Skip to content

Commit

Permalink
Enrollment app - add state variable to ensure setting of careplan date
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen authored and Amy Chen committed Jun 13, 2024
1 parent add4a4a commit cfb23a4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/EnrollmentApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type EnrollmenAppState = {
carePlanStartDate: Date | null;
selectedCarePlanStartDate: Date | null;
startDateModalOpen: boolean;
loaded: boolean;
}

export default class EnrollmentApp extends React.Component<{}, EnrollmenAppState> {
Expand All @@ -50,6 +51,7 @@ export default class EnrollmentApp extends React.Component<{}, EnrollmenAppState
carePlanStartDate: null,
selectedCarePlanStartDate: null,
startDateModalOpen: true,
loaded: false
};
}

Expand Down Expand Up @@ -174,6 +176,15 @@ export default class EnrollmentApp extends React.Component<{}, EnrollmenAppState
: existingCarePlan.created;
this.setState({
carePlanStartDate: new Date(startDate),
}, () => {
// make sure care plan date is set before presenting the view
this.setState({
loaded: true
});
});
} else {
this.setState({
loaded: true
});
}
}
Expand Down Expand Up @@ -364,9 +375,10 @@ export default class EnrollmentApp extends React.Component<{}, EnrollmenAppState
);
}
render(): React.ReactNode {
if (!this.state || !this.context) return <CircularProgress />;
if (!this.state || !this.context || !this.state.loaded) return <CircularProgress />;

let view = <CircularProgress />;

if (!this.state.carePlanStartDate) {
view = this.getCarePlanStartDateModalView();
} else if (this.state.activeCarePlan != null) {
Expand Down

0 comments on commit cfb23a4

Please sign in to comment.