### Description User & Metadata Loading ### Refs #4456 ### Demo https://github.com/twentyhq/twenty/assets/140154534/4c20fca6-feaf-45f6-ac50-6532d2ebf050 Fixes #4456 --------- 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>
29 lines
964 B
TypeScript
29 lines
964 B
TypeScript
import React from 'react';
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
import { ObjectMetadataItemsLoadEffect } from '@/object-metadata/components/ObjectMetadataItemsLoadEffect';
|
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
|
import { RelationPickerScope } from '@/object-record/relation-picker/scopes/RelationPickerScope';
|
|
import { UserOrMetadataLoader } from '~/loading/components/UserOrMetadataLoader';
|
|
|
|
export const ObjectMetadataItemsProvider = ({
|
|
children,
|
|
}: React.PropsWithChildren) => {
|
|
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
|
|
|
const shouldDisplayChildren = objectMetadataItems.length > 0;
|
|
|
|
return (
|
|
<>
|
|
<ObjectMetadataItemsLoadEffect />
|
|
{shouldDisplayChildren ? (
|
|
<RelationPickerScope relationPickerScopeId="relation-picker">
|
|
{children}
|
|
</RelationPickerScope>
|
|
) : (
|
|
<UserOrMetadataLoader />
|
|
)}
|
|
</>
|
|
);
|
|
};
|