1- import { useRef , useState } from 'react' ;
1+ import { Button , Fieldset , Table , TextInput } from 'nhsuk-react-components' ;
2+ import { getDocument } from 'pdfjs-dist' ;
3+ import { JSX , useRef , useState } from 'react' ;
4+ import { useNavigate } from 'react-router-dom' ;
5+ import { v4 as uuidv4 } from 'uuid' ;
6+ import useTitle from '../../../../helpers/hooks/useTitle' ;
7+ import {
8+ fileUploadErrorMessages ,
9+ PDF_PARSING_ERROR_TYPE ,
10+ UPLOAD_FILE_ERROR_TYPE ,
11+ } from '../../../../helpers/utils/fileUploadErrorMessages' ;
12+ import formatFileSize from '../../../../helpers/utils/formatFileSize' ;
13+ import { routeChildren , routes } from '../../../../types/generic/routes' ;
214import {
315 DOCUMENT_TYPE ,
416 DOCUMENT_UPLOAD_STATE ,
@@ -7,30 +19,18 @@ import {
719 UploadDocument ,
820 UploadFilesError ,
921} from '../../../../types/pages/UploadDocumentsPage/types' ;
10- import { v4 as uuidv4 } from 'uuid' ;
1122import BackButton from '../../../generic/backButton/BackButton' ;
12- import { useNavigate } from 'react-router-dom' ;
13- import { routeChildren , routes } from '../../../../types/generic/routes' ;
14- import useTitle from '../../../../helpers/hooks/useTitle' ;
15- import { Button , Fieldset , Table , TextInput } from 'nhsuk-react-components' ;
16- import formatFileSize from '../../../../helpers/utils/formatFileSize' ;
1723import LinkButton from '../../../generic/linkButton/LinkButton' ;
18- import { getDocument } from 'pdfjs-dist' ;
1924import PatientSummary , { PatientInfo } from '../../../generic/patientSummary/PatientSummary' ;
2025import ErrorBox from '../../../layout/errorBox/ErrorBox' ;
21- import {
22- fileUploadErrorMessages ,
23- PDF_PARSING_ERROR_TYPE ,
24- UPLOAD_FILE_ERROR_TYPE ,
25- } from '../../../../helpers/utils/fileUploadErrorMessages' ;
2626
2727export type Props = {
2828 setDocuments : SetUploadDocuments ;
2929 documents : Array < UploadDocument > ;
3030 documentType : DOCUMENT_TYPE ;
3131} ;
3232
33- const DocumentSelectStage = ( { documents, setDocuments, documentType } : Props ) => {
33+ const DocumentSelectStage = ( { documents, setDocuments, documentType } : Props ) : JSX . Element => {
3434 const fileInputRef = useRef < HTMLInputElement | null > ( null ) ;
3535 const [ noFilesSelected , setNoFilesSelected ] = useState < boolean > ( false ) ;
3636 const scrollToRef = useRef < HTMLDivElement > ( null ) ;
@@ -168,7 +168,7 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
168168 navigate ( routeChildren . DOCUMENT_UPLOAD_SELECT_ORDER ) ;
169169 } ;
170170
171- const DocumentRow = ( document : UploadDocument , index : number ) => {
171+ const DocumentRow = ( document : UploadDocument , index : number ) : JSX . Element => {
172172 return (
173173 < Table . Row key = { document . id } id = { document . file . name } >
174174 < Table . Cell className = { document . error ? 'error-cell' : '' } >
@@ -188,7 +188,7 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
188188 type = "button"
189189 aria-label = { `Remove ${ document . file . name } from selection` }
190190 className = "link-button"
191- onClick = { ( ) => {
191+ onClick = { ( ) : void => {
192192 onRemove ( index ) ;
193193 } }
194194 >
@@ -213,7 +213,7 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
213213
214214 useTitle ( { pageTitle : pageTitle ( ) } ) ;
215215
216- const errorDocs = ( ) => {
216+ const errorDocs = ( ) : UploadDocument [ ] => {
217217 return documents . filter ( ( doc ) => doc . error && doc . validated ) ;
218218 } ;
219219
@@ -296,7 +296,7 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
296296 id = "upload-files"
297297 tabIndex = { 0 }
298298 data-testid = "dropzone"
299- onDragOver = { ( e ) => {
299+ onDragOver = { ( e ) : void => {
300300 e . preventDefault ( ) ;
301301 } }
302302 onDrop = { onFileDrop }
@@ -312,20 +312,20 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
312312 multiple = { true }
313313 hidden
314314 accept = { allowedFileTypes ( ) }
315- onChange = { ( e : FileInputEvent ) => {
315+ onChange = { ( e : FileInputEvent ) : void => {
316316 onInput ( e ) ;
317317 e . target . value = '' ;
318318 } }
319319 // @ts -ignore The NHS Component library is outdated and does not allow for any reference other than a blank MutableRefObject
320- inputRef = { ( e : HTMLInputElement ) => {
320+ inputRef = { ( e : HTMLInputElement ) : void => {
321321 fileInputRef . current = e ;
322322 } }
323323 />
324324 < Button
325325 data-testid = { `upload-button-input` }
326326 type = { 'button' }
327327 className = { 'nhsuk-button nhsuk-button--secondary bottom-margin' }
328- onClick = { ( ) => {
328+ onClick = { ( ) : void => {
329329 fileInputRef . current ?. click ( ) ;
330330 } }
331331 aria-labelledby = "upload-fieldset-legend"
@@ -365,7 +365,7 @@ const DocumentSelectStage = ({ documents, setDocuments, documentType }: Props) =
365365 type = "button"
366366 className = "remove-all-button mb-5"
367367 data-testid = "remove-all-button"
368- onClick = { ( ) => {
368+ onClick = { ( ) : void => {
369369 navigate ( routeChildren . DOCUMENT_UPLOAD_REMOVE_ALL ) ;
370370 } }
371371 >
0 commit comments