Use search instead of findMany in relation pickers (#7798)

First step of #https://github.com/twentyhq/twenty/issues/3298.
Here we update the search endpoint to allow for a filter argument, which
we currently use in the relation pickers to restrict or exclude ids from
search.
In a future PR we will try to simplify the search logic in the FE
This commit is contained in:
Marie
2024-10-18 14:50:04 +02:00
committed by GitHub
parent 8cadcdf577
commit 6fef125965
15 changed files with 123 additions and 125 deletions

View File

@ -85,6 +85,7 @@ export const NavigationDrawerSectionForObjectMetadataItems = ({
objectMetadataItemsForNavigationItems.map(
(objectMetadataItem) => (
<NavigationDrawerItemForObjectMetadataItem
key={`navigation-drawer-item-${objectMetadataItem.id}`}
objectMetadataItem={objectMetadataItem}
/>
),

View File

@ -1,29 +0,0 @@
import { useEffect } from 'react';
import { useRelationPicker } from '@/object-record/relation-picker/hooks/useRelationPicker';
export const ObjectMetadataItemsRelationPickerEffect = ({
relationPickerScopeId,
}: {
relationPickerScopeId?: string;
} = {}) => {
const { setSearchQuery } = useRelationPicker({ relationPickerScopeId });
const computeFilterFields = (relationPickerType: string) => {
if (relationPickerType === 'company') {
return ['name'];
}
if (['workspaceMember', 'person'].includes(relationPickerType)) {
return ['name.firstName', 'name.lastName'];
}
return ['name'];
};
useEffect(() => {
setSearchQuery({ computeFilterFields });
}, [setSearchQuery]);
return <></>;
};