import { FormControl, InputLabel, Select, MenuItem } from '@mui/material'; import { getFieldOptions } from '../../utils/options'; import { FieldComponentProps } from '../../types/overrides'; export default function RelationField({ field, value, onChange, disabled, relationDataMap = {} }: FieldComponentProps) { if (!field.relation || !relationDataMap[field.relation]) { return null; } const relationData = relationDataMap[field.relation].data; const isArrayRelation = field.type === 'array'; const options = getFieldOptions(field, relationData); const keyField = field.enumOption?.key ?? 'id'; const normalizedValue = (() => { if (isArrayRelation && Array.isArray(value)) { return value.map((v: any) => (v != null && typeof v === 'object' ? String(v[keyField] ?? '') : String(v))); } if (value != null && typeof value === 'object') { return String(value[keyField] ?? ''); } return value ?? (isArrayRelation ? [] : ""); })(); return ( {field.label} ); }