-
Notifications
You must be signed in to change notification settings - Fork 0
DEMOS-1056 and DEMOS-1067 - Manage Contacts Updates #513
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
base: main
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
tresdonicf
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.
I believe this probably makes the codebase better but am having a tough time reasoning about what it currently does or is supposed to do - could you put some logic inside helper functions to try to clear this up?
| const currentRoles = selectedContacts.filter((c) => c.contactType); | ||
|
|
||
| const currentPrimaryPO = currentRoles.find( | ||
| (c) => c.contactType === "Project Officer" && c.isPrimary | ||
| ); | ||
| const savedPrimaryPO = savedContacts.find( | ||
| (c) => c.contactType === "Project Officer" && c.isPrimary | ||
| ); | ||
|
|
||
| if ( | ||
| currentPrimaryPO && | ||
| savedPrimaryPO && | ||
| currentPrimaryPO.personId !== savedPrimaryPO.personId | ||
| ) { | ||
| await setDemonstrationRoles({ | ||
| variables: { | ||
| input: [ | ||
| { | ||
| demonstrationId, | ||
| personId: currentPrimaryPO.personId, | ||
| roleId: "Project Officer", | ||
| isPrimary: true, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
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 be nice to throw some stuff like this in a helper function, it's a bit hard to follow what this currently does or is supposed to do
|
|
||
| const handleSearch = (value: string) => { | ||
| setSearchTerm(value); | ||
| if (value.length < 2) { |
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.
NB: Would be nice to declare const MIN_CHARACTERS_FOR_SEARCH = 2 at the top of the file
connor-parke-icf
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.
I feel like there may be more validation rules we're introducing here than are enforced in the database. I feel like there may have been conflicting requirements or a recent update that isnt in sync with what the database expects.
The main validation rules i was aware of are that
- a demonstration must have exactly one primary project officer
- a person can only be assigned to a role on a demonstration if they belong to the same state as the demonstration
- a person can only be assigned to a role that is allowed by their personType (idm role)
- a maximum of one assignment of each type can be the primary for that role
im seeing some validations around not being able to delete role assignments on primary non-project-officer roles for instance, that might should be allowed instead. Its kinda hard to tell, but i feel like we might can simplify some of the logic here; but i dont know if the requirements have changed. if they have we might should update the database to match (as a separate ticket).
ManageContactsDialog Improvements
This PR implements three key fixes to improve the contact management functionality: Fixed search filtering bug where the search field was showing all contacts instead of filtered results by adding robust client-side filtering with deduplication logic, Resolved Apollo constraint error "Cannot remove the primary project officer" by reordering mutations to set new primary contacts before removing old ones, and Enhanced user experience by removing auto-timeout behavior for primary contact warnings so they persist until the user explicitly saves or cancels the dialog.