import { Form, message } from 'antd' import { useForm } from 'antd/lib/form/Form' import React from 'react' import { FormDesignFragment, FormFieldFragment } from '../../graphql/fragment/form.fragment' import { StyledButton } from '../styled/button' import { StyledH1 } from '../styled/h1' import { StyledP } from '../styled/p' import { fieldTypes } from './types' import { TextType } from './types/text.type' import { FieldTypeProps } from './types/type.props' interface Props { field: FormFieldFragment design: FormDesignFragment // eslint-disable-next-line @typescript-eslint/no-explicit-any save: (data: any) => void next: () => void prev: () => void } export const Field: React.FC = ({ field, save, design, next, prev, ...props }) => { const [form] = useForm() const FieldInput: React.FC = fieldTypes[field.type] || TextType const finish = (data) => { console.log('received field data', data) save(data) next() } const error = async () => { await message.error('Check inputs!') } return (
{field.title} {field.description && ( {field.description} )}
{'Previous'}
{'Next'}
) }