Skip to content

Commit

Permalink
Fix remaining sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
RioKnightleyNHS committed Feb 15, 2024
1 parent 8c91a5e commit 9a8d7ef
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const DocumentInputForm = ({
>
Primary Care Support England
</a>
.
{'.'}
</li>
)}
{formType === DOCUMENT_TYPE.LLOYD_GEORGE && (
Expand All @@ -89,7 +89,7 @@ const DocumentInputForm = ({
</ul>
}
/>
<div role="region" aria-live="polite">
<div aria-live="polite">
{documents && documents.length > 0 && (
<Table caption="Chosen files" id="selected-documents-table">
<Table.Head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Table } from 'nhsuk-react-components';
import { SearchResult } from '../../../../types/generic/searchResult';
import { useState } from 'react';
import { getFormattedDatetime } from '../../../../helpers/utils/formatDatetime';

type Props = {
Expand All @@ -12,42 +11,39 @@ const DocumentSearchResults = (props: Props) => {
new Date(a.created) < new Date(b.created) ? 1 : -1;

const orderedResults = props.searchResults.sort(sortMethod);
const [searchResults, ,] = useState(orderedResults);
const tableCaption = <h2 style={{ fontSize: 32 }}>List of documents available</h2>;
return (
<>
<Table id="available-files-table-title" caption={tableCaption}>
<Table.Head>
<Table.Row>
<Table.Cell className={'table-column-header'}>Filename</Table.Cell>
<Table.Cell className={'table-column-header'}>Uploaded At</Table.Cell>
</Table.Row>
</Table.Head>
<Table.Body>
{searchResults.map((result, index) => (
<Table.Row
className={'available-files-row'}
id={'available-files-row-' + index}
key={`document-${index}`}
data-testid="search-result"
<Table id="available-files-table-title" caption={tableCaption}>
<Table.Head>
<Table.Row>
<Table.Cell className={'table-column-header'}>Filename</Table.Cell>
<Table.Cell className={'table-column-header'}>Uploaded At</Table.Cell>
</Table.Row>
</Table.Head>
<Table.Body>
{orderedResults.map((result, index) => (
<Table.Row
className={'available-files-row'}
id={'available-files-row-' + index}
key={`document-${result.fileName}`}
data-testid="search-result"
>
<Table.Cell
id={'available-files-row-' + index + '-filename'}
data-testid="filename"
>
{result.fileName}
</Table.Cell>
<Table.Cell
id={'available-files-row-' + index + '-created-date'}
data-testid="created"
>
<Table.Cell
id={'available-files-row-' + index + '-filename'}
data-testid="filename"
>
{result.fileName}
</Table.Cell>
<Table.Cell
id={'available-files-row-' + index + '-created-date'}
data-testid="created"
>
{getFormattedDatetime(new Date(result.created))}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
</>
{getFormattedDatetime(new Date(result.created))}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ const renderDocumentSearchResultsOptions = (downloadState: SUBMISSION_STATE) =>
nhsNumber={patient.nhsNumber}
downloadState={downloadState}
updateDownloadState={updateDownloadState}
numberOfFiles={7}
setIsDeletingDocuments={mockSetIsDeletingDocuments}
/>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type Props = {
function DeletionConfirmationStage({ numberOfFiles, setStage, setDownloadStage }: Props) {
const navigate = useNavigate();
const patientDetails = usePatient();
const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
const formattedNhsNumber = formatNhsNumber(nhsNumber);
const role = useRole();
const handleClick = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type Props = {

function LloydGeorgeFileInputStage({ documents, setDocuments, setStage }: Props) {
const patientDetails = usePatient();
const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
const formattedNhsNumber = formatNhsNumber(nhsNumber);
const dob: string = patientDetails?.birthDate
? getFormattedDate(new Date(patientDetails.birthDate))
Expand Down Expand Up @@ -142,6 +142,7 @@ function LloydGeorgeFileInputStage({ documents, setDocuments, setStage }: Props)
<Fieldset>
<div
role="button"
tabIndex={0}
data-testid="dropzone"
onDragOver={(e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function LloydGeorgeRecordStage({
required: true,
});

const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
const formattedNhsNumber = formatNhsNumber(nhsNumber);

const role = useRole();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {

const ReducedPatientInfo = ({ className }: Props) => {
const patientDetails = usePatient();
const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
const formattedNhsNumber = formatNhsNumber(nhsNumber);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { errorToParams } from '../../helpers/utils/errorToParams';
function DocumentSearchResultsPage() {
const patientDetails = usePatient();

const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
const [searchResults, setSearchResults] = useState<Array<SearchResult>>([]);
const [submissionState, setSubmissionState] = useState(SUBMISSION_STATE.INITIAL);
const [downloadState, setDownloadState] = useState(SUBMISSION_STATE.INITIAL);
Expand Down Expand Up @@ -98,7 +98,6 @@ function DocumentSearchResultsPage() {
nhsNumber={nhsNumber}
downloadState={downloadState}
updateDownloadState={handleUpdateDownloadState}
numberOfFiles={searchResults.length}
setIsDeletingDocuments={setIsDeletingDocuments}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function LloydGeorgeRecordPage() {
};

const onPageLoad = async () => {
const nhsNumber: string = patientDetails?.nhsNumber || '';
const nhsNumber: string = patientDetails?.nhsNumber ?? '';
try {
const { number_of_files, total_file_size_in_byte, last_updated, presign_url } =
await getLloydGeorgeRecord({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { UploadDocument } from '../../types/pages/UploadDocumentsPage/types';
import LloydGeorgeFileInputStage from '../../components/blocks/lloydGeorgeFileInputStage/LloydGeorgeFileInputStage';
import LloydGeorgeUploadComplete from '../../components/blocks/lloydGeorgeUploadComplete/LloydGeorgeUploadComplete';

type Props = {};

export enum LG_UPLOAD_STAGE {
SELECT = 0,
UPLOAD = 1,
COMPLETE = 2,
}

function LloydGeorgeUploadPage({}: Props) {
function LloydGeorgeUploadPage() {
const [stage, setStage] = useState<LG_UPLOAD_STAGE>(LG_UPLOAD_STAGE.SELECT);
const [documents, setDocuments] = useState<Array<UploadDocument>>([]);

Expand Down
2 changes: 1 addition & 1 deletion app/src/providers/patientProvider/PatientProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const TestComponent = (props: TestProps) => {

return (
<>
<p>NHS Number: {patientDetails?.nhsNumber || 'Null'}</p>
<p>NHS Number: {patientDetails?.nhsNumber ?? 'Null'}</p>
<p>Family Name: {patientDetails?.familyName || 'Null'}</p>
<button onClick={() => setPatientDetails(props.patientDetails)}>
Update NHS Number
Expand Down

0 comments on commit 9a8d7ef

Please sign in to comment.