-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enable user to Join Households #1022
base: deploy/6761-table-actions
Are you sure you want to change the base?
Conversation
@@ -56,6 +66,11 @@ const AddToHouseholdButton = ({ | |||
inputVariables: { projectId, clientId }, | |||
pickListArgs: { projectId, householdId }, | |||
localConstants: { householdId, projectCocCount: cocCount }, | |||
onFieldChange: (linkId?: string, value?: any) => { |
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.
@gigxz as you can see, this is still a draft with many todos, but this is the key part I'd like early feedback about!
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.
Thanks @martha I will take a closer look. I agree with you that RHF may make this a bit different, for example maybe we could hook into the RHF watch
functionality.
I'll explain the backend alternative I was thinking of, too, just to give some more detail. This is an approach where the backend would be solely responsible for determining whether there are conflicts:
- Similarly to how the Delete Client returns some structured JSON data related to a warning, the SubmitForm mutation could return structured data attached to the validation error
Client has another enrollment in this project that conflicts with this entry date.
that it already returns. That could be implemented here by adding something likedata : { conflicting_enrollment_id: 5 }
to the validation error. - If -- like with DeleteClient -- we included ALL the relevant information about conflicting enrollment(s), the validation error itself would have sufficient data on it for us to show the
Conflicting Enrollment
alert. - With this approach,
- There wouldn't be a need to do additional background queries based on the currently selected Entry Date
- The user wouldn't be made aware of the conflict (and the option to "join") until they have already tried to submit the form
- The logic for whether enrollments conflict or not would remain in one place (the Enrollment Validator here, which relies on the somewhat complicated
with_conflicting_dates
scope.) Since the logic is only in one place, we don't have to worry about making sure that the Backend and Frontend equivalents of "with conflicting dates" have perfectly matched logic. (Mis-matched logic would result in the backend error being surfaced but the frontend not showing the workflow option, or vice versa). - Once the
Conflicting Enrollment
alert is shown, the user would have the option to initiate the join, or change the Entry Date to something valid and re-submit.
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.
Thank you for the feedback @gigxz. I've made a start on your idea -- it's a bit rough, but I think something like this will be necessary to selectively override the FormDialog's default rendering of its error messages.
I also have a question about this part:
If -- like with DeleteClient -- we included ALL the relevant information about conflicting enrollment(s), the validation error itself would have sufficient data on it for us to show the Conflicting Enrollment alert.
Am I understanding the following correctly?
- the
data
attr of an error returned from the backend is just json, but can't be easily typed usingHmisSchema
objects - you're suggesting the error's
data
attr should return everything needed to render theConflictingClientAlert
, but not return all the data needed for the wholeJoinHouseholds
workflow, right?
If I got that right, then, I think I'd propose removing (descoping) the sentence "There [is/are] also [n] other household member[s] associated: [Additional Clients]" from the mocks here. It seems preferable to me to rely on our existing logic that lives in the schema objects for determining whether the current user has access to those clients, and/or access to view their names. The user will see those clients' names on the next step anyway, if they initiate the join workflow, so including them here seems more complicated than it's worth to me. (But maybe I am missing an easy way to do it.)
If I got that wrong, and you really did intend for the conflicting enrollment error message to include all the data necessary for the JoinHouseholds
workflow -- including client alerts of the associated household members, nested data that is expected in a certain format/type in the common column definitions we are using, etc. -- then I'll have some followup questions about how the typing should work (hand-pick the data we need in the enrollment validator, then cast on the frontend to the relevant gql typescript types? is there a better way?)
Thanks for your help!
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.
@martha good question, I didn't mean typing the data
field but rather just including enough information for the explanatory alert. If it makes sense to descope some content from the alert, I think that's OK. And it seems fine to me that the "join household workflow" itself would need to fetch additional data.
It is a bit brittle to have this un-typed contract between the backend and the frontend regarding what the supplemental error data looks like. The frontend should be as gracious as possible of course, so if the data
is missing or malformed it just shows the default message.
receivingHouseholdId: receivingHousehold.id, | ||
joiningEnrollmentInputs: joiningClients.map((hc) => { | ||
return { | ||
// todo @martha - discuss, should we use enrollmentLockVersion? |
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.
Let's discuss whether to use enrollmentLockVersion
here. I think I would propose de-scoping it and maybe ticketing it for a future improvement.
<Typography variant='body1'> | ||
Update joining clients' relationships{' '} | ||
{receivingHohName && <>to {receivingHohName}</>} | ||
{/* todo @martha - add warning here about entry dates, pending conversation with design */} |
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.
@@ -54,7 +54,10 @@ const DateWithRelativeTooltip = ({ | |||
> | |||
{formattedDate} | |||
{/* Include the tooltip text as visually hidden for accessibility */} | |||
<Box sx={visuallyHidden}>, {formattedDateRelative}</Box> | |||
{/* Add position: fixed to address visual bug when visuallyHidden is used inside dialog */} |
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.
Seems like when visuallyHidden
is used inside a dialog, it causes some surprising scroll behavior. I wasn't able to repro it on stackblitz using the latest mui version. I would propose cutting a separate ticket to track this down later (and see if it impacts anywhere else in our app, since we use visuallyHidden
all over the place)
Edit: Created https://github.com/open-path/Green-River/issues/7233
preFormComponent: clientAlerts.length > 0 && ( | ||
<ClientAlertStack clientAlerts={clientAlerts} /> | ||
), | ||
// This wrapper is necessary around the preFormComponent Stack, |
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 can create a separate ticket to improve this, as well
Edit: created https://github.com/open-path/Green-River/issues/7234
@@ -1,38 +1,46 @@ | |||
import { Button } from '@mui/material'; |
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.
Question about our directory structure here -- what is src/modules/household/components/elements/
? Should components/elements
be flattened into components
?
@gigxz ok! There is still some work to be done on the backend draft PR (including a system test), but I think this frontend work is now ready for your review. Thank you 🙏 |
@gigxz I'm converting this back to draft for now. As I've been working more on the Split workflow, I've been realizing how much code the 2 workflows share, and thinking I can do a better job of factoring this into reusable components to reduce code duplication. 🤔 I want to take a proper stab at that with a fresh brain Monday morning. |
Description
GH issue: https://github.com/open-path/Green-River/issues/5752
Depends on hmis-warehouse PR: greenriver/hmis-warehouse#5047
Summary of changes:
useClientAlerts
hook with an existing household from memory.Type of change
Checklist before requesting review