import Form from 'react-bootstrap/Form'; import { useTranslation } from 'react-i18next'; import { FieldConstraint, RecordConstraint } from '@stirling-pdf/shared-operations/src/dynamic-ui/OperatorConstraints' interface DynamicParameterFieldsProps { constraints: RecordConstraint; parentKeyPath?: string[]; } const DynamicParameterFields: React.FC = ({constraints, parentKeyPath=["DPF"]}) => { const { t } = useTranslation(); return (<> {Object.entries(constraints.record).map(([fieldName, value]) => { console.log(fieldName, value) const globallyUniqueId = joinKeyPath([...parentKeyPath, fieldName]); return
{fieldConstraintToElement(fieldName, parentKeyPath, globallyUniqueId, value)}
})} ); } function joinKeyPath(keyPath: string[]) { return keyPath.join("."); } function fieldConstraintToElement(fieldName: string, parentKeyPath: string[], globallyUniqueId: string, fieldConstraint: FieldConstraint) { if (Array.isArray(fieldConstraint.type)) { if (fieldConstraint.type.every(e => typeof e == 'string' || typeof e == 'number')) { return ( {fieldConstraint.type.map((option) => )} ); } else { return
Error: Field type '{fieldConstraint.type}' not supported
} } else if (typeof fieldConstraint.type == 'string') { switch (fieldConstraint.type) { case "file.pdf": return ; case "files.pdf": return ; case "string": return ; case "number": return ; default: return
Error: Field type '{fieldConstraint.type}' not supported
} } else if (fieldConstraint.type instanceof RecordConstraint) { //return return
Error: Field type 'RecordConstraint' not supported yet!
} return
Error: Field type '{fieldConstraint.type}' not supported
} export default DynamicParameterFields;