import type { FormikHelpers } from 'formik'; import { Field as FormikField, Form, Formik } from 'formik'; import type { ReactNode } from 'react'; import tw from 'twin.macro'; import { boolean, object, string } from 'yup'; import AdminBox from '@/components/admin/AdminBox'; import { Button } from '@/components/elements/button'; import Field from '@/components/elements/Field'; import Label from '@/components/elements/Label'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; interface Values { name: string; description: string; source: string; target: string; readOnly: string; userMountable: string; } interface Props { action: string; title: string; initialValues?: Values; onSubmit: (values: Values, helpers: FormikHelpers) => void; children?: ReactNode; } function MountForm({ action, title, initialValues, children, onSubmit }: Props) { const submit = (values: Values, helpers: FormikHelpers) => { onSubmit(values, helpers); }; if (!initialValues) { initialValues = { name: '', description: '', source: '', target: '', readOnly: '0', userMountable: '0', }; } return ( {({ isSubmitting, isValid }) => (
{children}
)}
); } export default MountForm;