import React from 'react'; import Modal, { RequiredModalProps } from '@/components/elements/Modal'; import { Form, Formik, FormikHelpers } from 'formik'; import { object, string } from 'yup'; import Field from '@/components/elements/Field'; import { ServerContext } from '@/state/server'; import { join } from 'path'; type Props = RequiredModalProps & { onFileNamed: (name: string) => void; }; interface Values { fileName: string; } export default ({ onFileNamed, onDismissed, ...props }: Props) => { const directory = ServerContext.useStoreState(state => state.files.directory); const submit = (values: Values, { setSubmitting }: FormikHelpers) => { onFileNamed(join(directory, values.fileName)); setSubmitting(false); }; return ( {({ resetForm }) => ( { resetForm(); onDismissed(); }} {...props} >
)}
); };