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

feat: [DHIS2-17192] show related stages widget on registration page #3880

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

simonadomnisoru
Copy link
Contributor

@simonadomnisoru simonadomnisoru commented Nov 14, 2024

DHIS2-17192

Tech summary:

  • Add the Related Stages widget to the registration page and new relationship page. To enable it, the program's "First stage appears on registration page" option must be true, and the first stage should be the from part of a related stages relationship type.
  • Move to DataEntries some common logic and converters
  • The related stage event takes precedence over the openAfterEnrollment flag
  • The related stage event takes precedence over the autogenerate flag
  • Cypress tests will be added in DHIS2-17853

@simonadomnisoru simonadomnisoru changed the title feat: [DHIS2-17192] show related stages Widget on registration page feat: [DHIS2-17192] show related stages widget on registration page Nov 14, 2024
@simonadomnisoru simonadomnisoru marked this pull request as ready for review November 14, 2024 13:49
@simonadomnisoru simonadomnisoru requested a review from a team as a code owner November 14, 2024 13:49
@simonadomnisoru simonadomnisoru marked this pull request as draft November 26, 2024 11:17
@simonadomnisoru simonadomnisoru marked this pull request as ready for review December 2, 2024 14:49
Copy link
Contributor

@henrikmv henrikmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

Comment on lines 16 to 17
'../../common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/dataEntryTrackedEntityInstance.types';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can TeiPayload be exported through the existing index file in the folder?

errorMessages,
saveAttempted,
actionTypesOptions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Not code implemented in this PR, but is it necessary to export the plain function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is no need to export this function. I fixed it now. Good catch!

@@ -7,7 +7,7 @@ import { handleAPIResponse, REQUESTED_ENTITIES } from '../../../utils/api';

type Props = {
stageId: ?string,
enrollmentId: string,
enrollmentId?: string,
scheduledLabel: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property is always defined, but the value can be undefined.

Suggested change
scheduledLabel: string,
enrollmentId: ?string,

Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really solid overall @simonadomnisoru! I have a few suggestions for adjustments here and there.

Comment on lines 186 to 189
programStageIdLinkedEventToRedirectTo:
relatedStageLinkedEvent && linkMode === RelatedStageModes.ENTER_DATA
? relatedStageLinkedEvent.programStage
: undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good time to simplify how we determine what event to redirect to. My suggestion would be that we in this function (buildTeiWithEnrollment) get the eventId for the event. For related stages we are generating the eventId on the client, we will have to do this for auto generated events too. Then we should be able to write the logic to determine the eventId (that we will redirect to). Having the related stage take precedence makes sense to me (like you already did).

This way we can simplify the epics in the chain quite a bit and the code would be easier to reason about.

Might be missing something of course. Happy to talk about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To elaborate: On line 159 in useBuildEnrollmentPayload add something like: const redirectEvent = getEventToOpen(.......);.

  1. Check for ENTER_DATA for related stages.
  2. Check for "Open data entry form after enrollment" on the stages. If a stage is found, Get an event for that stage among the auto-generated ones (and probably the "first stage appears on registration page" one).

Let's discuss this one.

@simonadomnisoru
Copy link
Contributor Author

Looks really solid overall @simonadomnisoru! I have a few suggestions for adjustments here and there.

@JoakimSM the suggestions have been implemented. Can you have another look? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants