-
Notifications
You must be signed in to change notification settings - Fork 22
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
'../../common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/dataEntryTrackedEntityInstance.types'; | ||
|
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
scheduledLabel: string, | |
enrollmentId: ?string, |
There was a problem hiding this 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.
ref={relatedStageRef} | ||
programId={passOnProps.programId} | ||
programStageId={firstStageMetaData.stage?.id} | ||
actionTypesOptions={relatedStageModesOptions} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to stick with either "action" or "mode" throughout? For this particular one, if we stick with actions: actionsOptions={relatedStageActionsOptions}
(I see that both mode and action are being used in code not introduced by this PR, would be great to fix those as well)
I do like the generic approach you have chosen here though 👍 Nice!
programStageIdLinkedEventToRedirectTo: | ||
relatedStageLinkedEvent && linkMode === RelatedStageModes.ENTER_DATA | ||
? relatedStageLinkedEvent.programStage | ||
: undefined, |
There was a problem hiding this comment.
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.
@@ -69,7 +68,7 @@ const getEventDetailsByLinkMode = ({ | |||
return ({ | |||
linkedEvent: { | |||
...baseEventDetails, | |||
scheduledAt: convertFn(clientRequestEvent.scheduledAt, dataElementTypes.DATE), | |||
scheduledAt: clientRequestEvent.scheduledAt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit worried about this change. Based on the naming it seems like we should have converted from clientToServer. Can you verify this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming was wrong as the data is in the server format. I renamed the variable to make it less confusing. Thanks for the feedback!
deriveAutoGenerateEvents, | ||
deriveFirstStageDuringRegistrationEvent, | ||
deriveRelatedStageEvent, | ||
} from '../../../Pages/New/RegistrationDataEntry/helpers'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the opportunity to move these files to DataEntries/EnrollmentRegistrationEntry/helpers
? From what I can see they belong in the DataEntries/EnrollmentRegistrationEntry
folder and are only invoked from this file.
|
||
const toEntity = entity.id ? entity : getRelationshipNewTei(entity.dataEntryId, entity.itemId, state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getRelationshipNewTei
was dead code I presume? (yes, we need a clean up of relationships)
@JoakimSM the suggestions have been implemented. Can you have another look? Thanks! |
DHIS2-17192
Tech summary:
from
part of a related stages relationship type.