import React, { useRef } from 'react'; import { useHistory } from 'react-router-dom'; import { Form, Formik } from 'formik'; import Input from '../../components/Input'; import Page from '../../containers/Page'; import { Action } from '../../lib/ServiceContext'; import { post } from '../../requests'; const TransfersUpload: React.FC = () => { const history = useHistory(); const inputRef = useRef(null); const handleSubmitFile = () => { const reader = new FileReader(); const file = inputRef?.current?.files?.[0]; if (file) { reader.readAsDataURL(file); reader.onload = (event: ProgressEvent) => { const uri = event.target?.result; post('/uploads', { uri }).then(history.goBack); }; } }; const actions: Action[] = [ { name: 'Назад', variant: 'outlined', onClick: history.goBack }, { name: 'Загрузить', type: 'submit', form: 'form' }, ]; return (
); }; export default TransfersUpload;