From ef742ea9b2f246f74eae74169675a331679ad41c Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Fri, 26 Mar 2021 01:56:04 +0300
Subject: feat: add strong typing where possible

---
 src/services/transfers/TransfersUpload.tsx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'src/services/transfers/TransfersUpload.tsx')

diff --git a/src/services/transfers/TransfersUpload.tsx b/src/services/transfers/TransfersUpload.tsx
index c14a5c1..56bcd7e 100644
--- a/src/services/transfers/TransfersUpload.tsx
+++ b/src/services/transfers/TransfersUpload.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useRef } from 'react';
 import { useHistory } from 'react-router-dom';
 import { Form, Formik } from 'formik';
 import Input from '../../components/Input';
@@ -8,15 +8,15 @@ import { post } from '../../requests';
 
 const TransfersUpload: React.FC = () => {
   const history = useHistory();
+  const inputRef = useRef<HTMLInputElement>(null);
 
   const handleSubmitFile = () => {
     const reader = new FileReader();
-    const element = document.getElementById('file') as HTMLInputElement;
-    const file = element?.files?.[0];
+    const file = inputRef?.current?.files?.[0];
     if (file) {
       reader.readAsDataURL(file);
-      reader.onload = (e: any) => {
-        const uri = e.target.result;
+      reader.onload = (event: ProgressEvent<FileReader>) => {
+        const uri = event.target?.result;
         post('/uploads', { uri }).then(history.goBack);
       };
     }
@@ -34,7 +34,7 @@ const TransfersUpload: React.FC = () => {
     >
       <Formik onSubmit={handleSubmitFile} initialValues={{}}>
         <Form id="form">
-          <Input name="file" type="file" accept=".pdf" label="Прикрепите файл" id="file" />
+          <Input name="file" type="file" accept=".pdf" label="Прикрепите файл" ref={inputRef} />
         </Form>
       </Formik>
     </Page>
-- 
cgit v1.2.3

