-
Notifications
You must be signed in to change notification settings - Fork 35
feat: pass enrollment dates to form field plugins in widget profile #4389
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
Conversation
- Create useEnrollmentDatesForPlugin hook to fetch enrollment dates - Pass enrollmentId through LayoutComponentConfig to WidgetProfile - Build pluginContext with enrolledAt and occurredAt values - Add console error for attempted date updates (read-only in profile) - Pass pluginContext down through DataEntry component chain Co-Authored-By: Eirik <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
eirikhaugstulen
left a comment
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.
Great work, Devin. Some minor comments.
src/core_modules/capture-core/components/DataEntry/DataEntry.component.tsx
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/WidgetProfile/DataEntry/dataEntry.types.ts
Show resolved
Hide resolved
src/core_modules/capture-core/components/WidgetProfile/hooks/useEnrollmentDatesForPlugin.ts
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/WidgetProfile/hooks/useEnrollmentDatesForPlugin.ts
Outdated
Show resolved
Hide resolved
- Import and use PluginContext type instead of any in DataEntryOutputProps - Update query key from ['enrollmentDatesForPlugin'] to ['WidgetProfile', 'pluginContext'] - Aligns with project conventions for query key naming Addresses review feedback on PR #4389 Co-Authored-By: Eirik <[email protected]>
- Deleted useEnrollmentDatesForPlugin hook - Removed enrollmentId prop from WidgetProfile component chain - Created pluginContext in DataEntry.container using enrollment data from context - Memoized pluginContext with useMemo as requested This simplifies the implementation by reusing existing enrollment data already fetched by useLifecycle hook. Co-Authored-By: Eirik <[email protected]>
|
Thanks for the context, Simona! I understand the trade-off here. In this case, the If/when the widgets are extracted into a separate plugin, this import would indeed need to be addressed as part of that refactoring effort. Thanks for flagging it! |
|
|
🚀 Deployed on https://deploy-preview-4389.capture.netlify.dhis2.org |
# [104.5.0](v104.4.0...v104.5.0) (2025-10-23) ### Features * pass enrollment dates to form field plugins in widget profile ([#4389](#4389)) ([f94a2b1](f94a2b1))
|
🎉 This PR is included in version 104.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |



feat: pass enrollment dates to form field plugins in widget profile
Summary
This PR enables form field plugins to access enrollment dates (
enrolledAtandoccurredAt) when editing tracked entities in the widget profile. Previously, these dates were only available in the registration page context, causing plugins that depend on them to break in the profile widget edit modal.Implementation:
useLifecyclehook in the profile widget's DataEntry containerpluginContextobject withenrolledAtandoccurredAtas read-only fieldspluginContextthrough the DataEntry component chain to reach form field pluginsPluginContextTypeScript type throughout the chainReview & Testing Checklist for Human
enrolledAt/occurredAtcan access these values when editing in the profile widget. I haven't tested with real plugins.enrollmentobject fromuseLifecyclealways hasenrolledAtandoccurredAtfields when editing in the profile widget context.Notes
Recommended test plan:
enrolledAtoroccurredAtfrom the plugin contextImplementation details:
useLifecyclehook's context, which fetches it from Redux state (enrollmentDomain.enrollment)['WidgetProfile', 'pluginContext', enrollmentId](though this is no longer used after refactoring)Session details: