feat: get object metadata from backend in Object Detail and New Field… (#2122)

* feat: get object metadata from backend in Object Detail and New Field - Step 1

Closes #2008

* refactor: add useLazyLoadIcon hook
This commit is contained in:
Thaïs
2023-10-19 16:58:18 +02:00
committed by GitHub
parent bea9d0835b
commit f35ea19f4d
12 changed files with 133 additions and 86 deletions

View File

@ -3,16 +3,18 @@ import styled from '@emotion/styled';
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
import { useLazyLoadIcon } from '@/ui/input/hooks/useLazyLoadIcon';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow';
import { Field } from '~/generated-metadata/graphql';
import { ObjectFieldItem } from '../../types/ObjectFieldItem';
import { ObjectFieldDataType } from '../../types/ObjectFieldDataType';
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
type SettingsObjectFieldItemTableRowProps = {
ActionIcon: IconComponent;
fieldItem: ObjectFieldItem;
fieldItem: Field;
};
export const StyledObjectFieldTableRow = styled(TableRow)`
@ -34,18 +36,19 @@ export const SettingsObjectFieldItemTableRow = ({
fieldItem,
}: SettingsObjectFieldItemTableRowProps) => {
const theme = useTheme();
const { Icon } = useLazyLoadIcon(fieldItem.icon ?? '');
return (
<StyledObjectFieldTableRow>
<StyledNameTableCell>
<fieldItem.Icon size={theme.icon.size.md} />
{fieldItem.name}
{!!Icon && <Icon size={theme.icon.size.md} />}
{fieldItem.label}
</StyledNameTableCell>
<TableCell>{fieldItem.isCustom ? 'Custom' : 'Standard'}</TableCell>
<TableCell>
{fieldItem.type === 'standard' ? 'Standard' : 'Custom'}
</TableCell>
<TableCell>
<SettingsObjectFieldDataType value={fieldItem.dataType} />
<SettingsObjectFieldDataType
value={fieldItem.type as ObjectFieldDataType}
/>
</TableCell>
<StyledIconTableCell>
<LightIconButton Icon={ActionIcon} accent="tertiary" />