blob: bddd0adcf1e5aca74cc025ddc9d60ceb9444b1ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Form, Formik } from 'formik';
import Button from '../components/Button';
import Input from '../components/Input';
import Page, { Action } from './Page';
import { post } from '../requests';
const TransfersUpload: React.FC = () => {
const history = useHistory();
const handleSubmitFile = () => {
const reader = new FileReader();
const file = document.getElementById('file').files[0];
reader.readAsDataURL(file);
reader.onload = (e: any) => {
const uri = e.target.result;
post('/uploads', { uri }).then(history.goBack);
};
};
const actions: Action[] = [
{ name: 'Назад', variant: 'outlined', onClick: history.goBack },
{ name: 'Загрузить', type: 'submit', form: 'form' },
];
return (
<Page
title="Загрузить выписку"
actions={actions}
>
<Formik onSubmit={handleSubmitFile} initialValues={{}}>
<Form id="form">
<Input name="file" type="file" accept=".pdf" label="Прикрепите файл" id="file" />
</Form>
</Formik>
</Page>
);
};
export default TransfersUpload;
|