import { useEffect } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { ObjectFieldItemTableRow, StyledObjectFieldTableRow, } from '@/settings/objects/components/ObjectFieldItemTableRow'; import { activeFieldItems, activeObjectItems, disabledFieldItems, } from '@/settings/objects/constants/mockObjects'; import { objectSettingsWidth } from '@/settings/objects/constants/objectSettings'; import { AppPath } from '@/types/AppPath'; import { IconDotsVertical, IconPlus, IconSettings } from '@/ui/display/icon'; import { Tag } from '@/ui/display/tag/components/Tag'; import { H2Title } from '@/ui/display/typography/components/H2Title'; import { Button } from '@/ui/input/button/components/Button'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Table } from '@/ui/layout/table/components/Table'; import { TableCell } from '@/ui/layout/table/components/TableCell'; import { TableHeader } from '@/ui/layout/table/components/TableHeader'; import { TableRow } from '@/ui/layout/table/components/TableRow'; import { TableSection } from '@/ui/layout/table/components/TableSection'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; const StyledContainer = styled.div` display: flex; flex-direction: column; height: fit-content; padding: ${({ theme }) => theme.spacing(8)}; width: ${objectSettingsWidth}; `; const StyledFlexContainer = styled.div` display: flex; justify-content: flex-end; `; const StyledBreadcrumb = styled(Breadcrumb)` margin-bottom: ${({ theme }) => theme.spacing(8)}; `; const StyledAddFieldButton = styled(Button)` align-self: flex-end; margin-top: ${({ theme }) => theme.spacing(2)}; `; const StyledIconTableCell = styled(TableCell)` justify-content: center; padding-right: ${({ theme }) => theme.spacing(1)}; `; const StyledTableRow = styled(TableRow)` background-color: ${({ theme }) => theme.background.secondary}; border: ${({ theme }) => theme.border.color.medium}; `; const StyledNameTableCell = styled(TableCell)` color: ${({ theme }) => theme.font.color.primary}; gap: ${({ theme }) => theme.spacing(2)}; `; const StyledTag = styled(Tag)` box-sizing: border-box; height: ${({ theme }) => theme.spacing(4)}; `; const StyledIconDotsVertical = styled(IconDotsVertical)` color: ${({ theme }) => theme.font.color.tertiary}; `; export const SettingsObjectDetail = () => { const navigate = useNavigate(); const theme = useTheme(); const { pluralObjectName = '' } = useParams(); const activeObject = activeObjectItems.find( (activeObject) => activeObject.name.toLowerCase() === pluralObjectName, ); useEffect(() => { if (!activeObject) navigate(AppPath.NotFound); }, [activeObject, navigate]); return ( {activeObject ? ( ) : ( '' )} {activeObject?.name} {activeObject?.type === 'standard' ? ( ) : ( )} navigate(`/settings/objects/${pluralObjectName}/edit`) } /> Name Field type Data type {activeFieldItems.map((fieldItem) => ( ))} {!!disabledFieldItems.length && ( {disabledFieldItems.map((fieldItem) => ( ))} )}
); };