* Fix naming issue Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Fix more tests Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Revert unnecessary changes Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Refactor according to self-review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Fix graphql mocks not working anymore --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
30 lines
909 B
TypeScript
30 lines
909 B
TypeScript
import { selectorFamily } from 'recoil';
|
|
|
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
|
|
|
export const objectMetadataItemFamilySelector = selectorFamily<
|
|
ObjectMetadataItem | null,
|
|
{ objectNameSingular?: string; objectNamePlural?: string }
|
|
>({
|
|
key: 'objectMetadataItemFamilySelector',
|
|
get:
|
|
({
|
|
objectNameSingular,
|
|
objectNamePlural,
|
|
}: {
|
|
objectNameSingular?: string;
|
|
objectNamePlural?: string;
|
|
}) =>
|
|
({ get }) => {
|
|
const objectMetadataItems = get(objectMetadataItemsState);
|
|
return (
|
|
objectMetadataItems.find(
|
|
(objectMetadataItem) =>
|
|
objectMetadataItem.nameSingular === objectNameSingular ||
|
|
objectMetadataItem.namePlural === objectNamePlural,
|
|
) ?? null
|
|
);
|
|
},
|
|
});
|