Skip to content

Commit 5c04335

Browse files
[PRME-296] Add missing function return types
1 parent 2382df3 commit 5c04335

File tree

108 files changed

+406
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+406
-489
lines changed

app/src/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AwsRum, AwsRumConfig } from 'aws-rum-web';
77
import { NdrTokenData } from './types/generic/ndrTokenData';
88
import { decodeJwtToken } from './helpers/utils/jwtDecoder';
99
import PatientAccessAuditProvider from './providers/patientAccessAuditProvider/PatientAccessAuditProvider';
10+
import { JSX } from 'react';
1011

1112
const cypress =
1213
import.meta.env.VITE_MONITOR_ACCOUNT_ID === 'not provided yet' &&
@@ -58,7 +59,7 @@ if (import.meta.env.VITE_ENVIRONMENT === 'development' && !cypress) {
5859
}
5960
}
6061

61-
function App() {
62+
const App = (): JSX.Element => {
6263
return (
6364
<ConfigProvider>
6465
<SessionProvider>
@@ -70,5 +71,5 @@ function App() {
7071
</SessionProvider>
7172
</ConfigProvider>
7273
);
73-
}
74+
};
7475
export default App;

app/src/components/blocks/_arf/completeStage/CompleteStage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
documents: Array<UploadDocument>;
88
}
99

10-
function CompleteStage({ documents }: Props) {
10+
const CompleteStage = ({ documents }: Props): React.JSX.Element => {
1111
const navigate = useNavigate();
1212

1313
return (
@@ -26,6 +26,6 @@ function CompleteStage({ documents }: Props) {
2626
</Button>
2727
</>
2828
);
29-
}
29+
};
3030

3131
export default CompleteStage;

app/src/components/blocks/_arf/documentSearchResults/DocumentSearchResults.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ type Props = {
66
searchResults: Array<SearchResult>;
77
};
88

9-
const DocumentSearchResults = (props: Props) => {
10-
const sortMethod = (a: SearchResult, b: SearchResult) =>
9+
const DocumentSearchResults = (props: Props): React.JSX.Element => {
10+
const sortMethod = (a: SearchResult, b: SearchResult): number =>
1111
new Date(a.created) < new Date(b.created) ? 1 : -1;
1212

1313
const orderedResults = [...props.searchResults].sort(sortMethod);
1414
const tableCaption = (
1515
<h2 className="document-search-table-caption">List of documents available</h2>
1616
);
17+
1718
return (
1819
<Table id="available-files-table-title" caption={tableCaption}>
1920
<Table.Head>

app/src/components/blocks/_arf/documentSearchResultsOptions/DocumentSearchResultsOptions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface DownloadLinkAttributes {
2222
filename: string;
2323
}
2424

25-
const DocumentSearchResultsOptions = (props: Props) => {
25+
const DocumentSearchResultsOptions = (props: Props): React.JSX.Element => {
2626
const navigate = useNavigate();
2727
const baseUrl = useBaseAPIUrl();
2828
const baseHeaders = useBaseAPIHeaders();
@@ -54,7 +54,7 @@ const DocumentSearchResultsOptions = (props: Props) => {
5454
}
5555
}, [linkAttributes]);
5656

57-
const downloadAll = async () => {
57+
const downloadAll = async (): Promise<void> => {
5858
props.updateDownloadState(SUBMISSION_STATE.PENDING);
5959
try {
6060
const preSignedUrl = await getPresignedUrlForZip({
@@ -80,7 +80,7 @@ const DocumentSearchResultsOptions = (props: Props) => {
8080
}
8181
};
8282

83-
const deleteAllDocuments = () => {
83+
const deleteAllDocuments = (): void => {
8484
navigate(routeChildren.ARF_DELETE_CONFIRMATION);
8585
};
8686

app/src/components/blocks/_arf/selectStage/SelectStage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ interface Props {
2121
startUpload: () => Promise<void>;
2222
}
2323

24-
function SelectStage({ setDocuments, documents, startUpload }: Readonly<Props>) {
24+
const SelectStage = ({
25+
setDocuments,
26+
documents,
27+
startUpload,
28+
}: Readonly<Props>): React.JSX.Element => {
2529
const arfInputRef = useRef<HTMLInputElement | null>(null);
2630

2731
const hasFileInput = documents.length > 0;
@@ -107,6 +111,6 @@ function SelectStage({ setDocuments, documents, startUpload }: Readonly<Props>)
107111
</form>
108112
</>
109113
);
110-
}
114+
};
111115

112116
export default SelectStage;

app/src/components/blocks/_arf/uploadingStage/UploadingStage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
documents: Array<UploadDocument>;
1313
}
1414

15-
function UploadingStage({ documents }: Props) {
15+
const UploadingStage = ({ documents }: Props): React.JSX.Element => {
1616
const pageHeader = 'Your documents are uploading';
1717
useTitle({ pageTitle: 'Uploading documents' });
1818

@@ -63,6 +63,6 @@ function UploadingStage({ documents }: Props) {
6363
</Table>
6464
</>
6565
);
66-
}
66+
};
6767

6868
export default UploadingStage;

app/src/components/blocks/_delete/deleteResultStage/DeleteResultStage.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Dispatch, MouseEvent, SetStateAction } from 'react';
1+
import { Dispatch, MouseEvent, SetStateAction } from 'react';
22
import { ButtonLink, Card } from 'nhsuk-react-components';
33
import { routes } from '../../../../types/generic/routes';
44
import { Link, useNavigate } from 'react-router-dom';
@@ -13,20 +13,22 @@ export type Props = {
1313
setDownloadStage?: Dispatch<SetStateAction<DOWNLOAD_STAGE>>;
1414
};
1515

16-
function DeleteResultStage({ numberOfFiles, setDownloadStage }: Props) {
16+
const DeleteResultStage = ({ numberOfFiles, setDownloadStage }: Props): React.JSX.Element => {
1717
const navigate = useNavigate();
1818
const role = useRole();
1919

20-
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
20+
const handleClick = (e: MouseEvent<HTMLAnchorElement>): void => {
2121
e.preventDefault();
2222
if (setDownloadStage) {
2323
setDownloadStage(DOWNLOAD_STAGE.REFRESH);
2424
}
2525
navigate(routes.LLOYD_GEORGE);
2626
};
27+
2728
const isGP = role === REPOSITORY_ROLE.GP_ADMIN || role === REPOSITORY_ROLE.GP_CLINICAL;
2829
const pageHeader = 'You have permanently removed the record of:';
2930
useTitle({ pageTitle: pageHeader });
31+
3032
return (
3133
<div className="deletion-complete">
3234
<Card className="deletion-complete_card">
@@ -86,7 +88,7 @@ function DeleteResultStage({ numberOfFiles, setDownloadStage }: Props) {
8688
id="start-again-link"
8789
data-testid="start-again-link"
8890
to=""
89-
onClick={(e) => {
91+
onClick={(e): void => {
9092
e.preventDefault();
9193
navigate(routes.START);
9294
}}
@@ -97,6 +99,6 @@ function DeleteResultStage({ numberOfFiles, setDownloadStage }: Props) {
9799
</p>
98100
</div>
99101
);
100-
}
102+
};
101103

102104
export default DeleteResultStage;

app/src/components/blocks/_delete/deleteSubmitStage/DeleteSubmitStage.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ type IndexViewProps = {
4646
resetDocState: () => void;
4747
};
4848

49-
const DeleteSubmitStageIndexView = ({ docType, recordType, resetDocState }: IndexViewProps) => {
49+
const DeleteSubmitStageIndexView = ({
50+
docType,
51+
recordType,
52+
resetDocState,
53+
}: IndexViewProps): React.JSX.Element => {
5054
const patientDetails = usePatient();
5155
const role = useRole();
5256
const { register, handleSubmit } = useForm();
@@ -62,8 +66,8 @@ const DeleteSubmitStageIndexView = ({ docType, recordType, resetDocState }: Inde
6266
'Select whether you want to permanently delete these patient files';
6367
const userIsGP = role === REPOSITORY_ROLE.GP_ADMIN || role === REPOSITORY_ROLE.GP_CLINICAL;
6468

65-
const handleYesOption = async () => {
66-
const onSuccess = () => {
69+
const handleYesOption = async (): Promise<void> => {
70+
const onSuccess = (): void => {
6771
resetDocState();
6872
setDeletionStage(SUBMISSION_STATE.SUCCEEDED);
6973
if (userIsGP) {
@@ -99,15 +103,15 @@ const DeleteSubmitStageIndexView = ({ docType, recordType, resetDocState }: Inde
99103
}
100104
};
101105

102-
const handleNoOption = () => {
106+
const handleNoOption = (): void => {
103107
if (role === REPOSITORY_ROLE.GP_ADMIN) {
104108
navigate(routes.LLOYD_GEORGE);
105109
} else if (role === REPOSITORY_ROLE.PCSE) {
106110
navigate(routes.ARF_OVERVIEW);
107111
}
108112
};
109113

110-
const submit = async (fieldValues: FieldValues) => {
114+
const submit = async (fieldValues: FieldValues): Promise<void> => {
111115
const allowedRoles = [REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.PCSE];
112116
if (role && allowedRoles.includes(role)) {
113117
if (fieldValues.deleteDocs === DELETE_DOCUMENTS_OPTION.YES) {
@@ -224,13 +228,13 @@ const DeleteSubmitStageIndexView = ({ docType, recordType, resetDocState }: Inde
224228
);
225229
};
226230

227-
function DeleteSubmitStage({
231+
const DeleteSubmitStage = ({
228232
docType,
229233
numberOfFiles,
230234
setDownloadStage,
231235
recordType,
232236
resetDocState,
233-
}: Props) {
237+
}: Props): React.JSX.Element => {
234238
const pageTitle = `You are removing the ${recordType} record of:`;
235239
useTitle({ pageTitle });
236240

@@ -271,5 +275,5 @@ function DeleteSubmitStage({
271275
<Outlet />
272276
</>
273277
);
274-
}
278+
};
275279
export default DeleteSubmitStage;

app/src/components/blocks/_delete/removeRecordStage/RemoveRecordStage.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ export type Props = {
3333
resetDocState: () => void;
3434
};
3535

36-
function RemoveRecordStage({ numberOfFiles, recordType, setDownloadStage, resetDocState }: Props) {
36+
const RemoveRecordStage = ({
37+
numberOfFiles,
38+
recordType,
39+
setDownloadStage,
40+
resetDocState,
41+
}: Props): React.JSX.Element => {
3742
useTitle({ pageTitle: 'Remove record' });
3843
const patientDetails = usePatient();
3944
const [submissionState, setSubmissionState] = useState(SUBMISSION_STATE.PENDING);
@@ -49,12 +54,12 @@ function RemoveRecordStage({ numberOfFiles, recordType, setDownloadStage, resetD
4954

5055
const mounted = useRef(false);
5156
useEffect(() => {
52-
const onSuccess = (result: Array<SearchResult>) => {
57+
const onSuccess = (result: Array<SearchResult>): void => {
5358
setSearchResults(result);
5459
setSubmissionState(SUBMISSION_STATE.SUCCEEDED);
5560
};
5661

57-
const onPageLoad = async () => {
62+
const onPageLoad = async (): Promise<void> => {
5863
try {
5964
const results = await getDocumentSearchResults({
6065
nhsNumber,
@@ -92,7 +97,7 @@ function RemoveRecordStage({ numberOfFiles, recordType, setDownloadStage, resetD
9297

9398
const hasDocuments = !!searchResults.length && !!patientDetails;
9499

95-
const PageIndexView = () => (
100+
const PageIndexView = (): React.JSX.Element => (
96101
<>
97102
<BackButton />
98103
<h1>Remove this {recordType} record</h1>
@@ -166,7 +171,7 @@ function RemoveRecordStage({ numberOfFiles, recordType, setDownloadStage, resetD
166171
{submissionState === SUBMISSION_STATE.SUCCEEDED && (
167172
<Button
168173
data-testid="remove-btn"
169-
onClick={() => {
174+
onClick={(): void => {
170175
navigate(routeChildren.LLOYD_GEORGE_DELETE_CONFIRMATION);
171176
}}
172177
>
@@ -217,5 +222,5 @@ function RemoveRecordStage({ numberOfFiles, recordType, setDownloadStage, resetD
217222
<Outlet></Outlet>
218223
</>
219224
);
220-
}
225+
};
221226
export default RemoveRecordStage;

app/src/components/blocks/_documentUpload/documentSelectOrderStage/DocumentSelectOrderStage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ const DocumentSelectOrderStage = ({
302302
<Table.Cell>
303303
<Link
304304
to=""
305-
onClick={() => viewPdfFile(document.file)}
305+
onClick={(): void => {
306+
void viewPdfFile(document.file);
307+
}}
306308
aria-label="Preview - opens in a new tab"
307309
data-testid={`document-preview-${document.id}`}
308310
>

0 commit comments

Comments
 (0)