🚸(frontend) prevent duplicate invite user row in DocShareModal

Modify the DocShareModal to avoid showing the invite user row when the
email already exists in the search results, preventing redundant invite
options
This commit is contained in:
Nathan Panchout
2025-01-29 11:20:21 +01:00
committed by Anthony LC
parent 3b151cf580
commit 9b95a9c551

View File

@@ -137,17 +137,20 @@ export const DocShareModal = ({ doc, onClose }: Props) => {
short_name: '',
};
const hasEmailInUsers = users.some((user) => user.email === userQuery);
return {
groupName: t('Search user result'),
elements: users,
endActions: isEmail
? [
{
content: <DocShareModalInviteUserRow user={newUser} />,
onSelect: () => void onSelect(newUser),
},
]
: undefined,
endActions:
isEmail && !hasEmailInUsers
? [
{
content: <DocShareModalInviteUserRow user={newUser} />,
onSelect: () => void onSelect(newUser),
},
]
: undefined,
};
}, [searchUsersQuery.data, t, userQuery]);