import React from 'react'; import { reportError, useConfig } from '@openmrs/esm-framework'; import { builtInFields, type RegistrationConfig } from '../../config-schema'; import { AddressComponent } from './address/address-field.component'; import { CauseOfDeathField } from './cause-of-death/cause-of-death.component'; import { CustomField } from './custom-field.component'; import { DateAndTimeOfDeathField } from './date-and-time-of-death/date-and-time-of-death.component'; import { DobField } from './dob/dob.component'; import { GenderField } from './gender/gender-field.component'; import { Identifiers } from './id/id-field.component'; import { NameField } from './name/name-field.component'; import { PhoneField } from './phone/phone-field.component'; export interface FieldProps { name: string; } export function Field({ name }: FieldProps) { const config = useConfig(); if ( !(builtInFields as ReadonlyArray).includes(name) && !config.fieldDefinitions.some((def) => def.id === name) ) { reportError( `Invalid field name '${name}'. Valid options are '${config.fieldDefinitions .map((def) => def.id) .concat(builtInFields) .join("', '")}'.`, ); return null; } switch (name) { case 'name': return ; case 'gender': return ; case 'dob': return ; case 'dateAndTimeOfDeath': return ; case 'causeOfDeath': return ; case 'address': return ; case 'id': return ; case 'phone': return ; default: return ; } }