Skip to content

Conversation

@nunesmlucas
Copy link
Member

@nunesmlucas nunesmlucas commented Nov 17, 2025

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.

@github-actions github-actions bot added the client Relates to the client. label Nov 17, 2025
@demos-git-service-account
Copy link
Contributor

demos-git-service-account commented Nov 17, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@nunesmlucas nunesmlucas changed the title DEMOS-1056 DEMOS-1056 and DEMOS-1067 - Manage Contacts Updates Nov 17, 2025
@nunesmlucas nunesmlucas requested a review from a team November 18, 2025 17:14
Copy link
Contributor

@tresdonicf tresdonicf left a 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?

Comment on lines +420 to +446
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,
},
],
},
});

Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Contributor

@connor-parke-icf connor-parke-icf left a 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

  1. a demonstration must have exactly one primary project officer
  2. a person can only be assigned to a role on a demonstration if they belong to the same state as the demonstration
  3. a person can only be assigned to a role that is allowed by their personType (idm role)
  4. 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Relates to the client.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants