Skip to content

Commit

Permalink
code review modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Alexander committed May 16, 2024
1 parent d2ca0b2 commit e4fc991
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,78 +136,67 @@ function DeleteDocumentsStage({
};
useTitle({ pageTitle: 'Delete files' });

const PageIndexView = () => (
<>
<BackLink onClick={handleNoOption} href="#">
Back
</BackLink>
{deletionStage === SUBMISSION_STATE.FAILED && <ServiceError />}
{showNoOptionSelectedMessage && (
<ErrorBox
messageTitle={'There is a problem '}
messageLinkBody={'You must select an option'}
errorBoxSummaryId={'error-box-summary'}
errorInputLink={'#delete-docs'}
dataTestId={'delete-error-box'}
/>
)}
<form onSubmit={handleSubmit(submit)}>
<Fieldset id="radio-selection">
<Fieldset.Legend isPageHeading>
Are you sure you want to permanently delete files for:
</Fieldset.Legend>
<div>{patientInfo}</div>
<Radios
id="delete-docs"
error={showNoOptionSelectedMessage && noOptionSelectedError}
>
<Radios.Radio
value={DELETE_DOCUMENTS_OPTION.YES}
inputRef={deleteDocsRef}
{...radioProps}
id="yes-radio-button"
data-testid="yes-radio-btn"
>
Yes
</Radios.Radio>
<Radios.Radio
value={DELETE_DOCUMENTS_OPTION.NO}
inputRef={deleteDocsRef}
{...radioProps}
id="no-radio-button"
data-testid="no-radio-btn"
>
No
</Radios.Radio>
</Radios>
</Fieldset>
{deletionStage === SUBMISSION_STATE.PENDING ? (
<SpinnerButton id="delete-docs-spinner" status="Deleting..." disabled={true} />
) : (
<Button type="submit" id="delete-submit-button" data-testid="delete-submit-btn">
Continue
</Button>
)}
</form>
</>
);

return (
<>
<div>
<Routes>
<Route
index
element={
<>
<BackLink onClick={handleNoOption} href="#">
Back
</BackLink>
{deletionStage === SUBMISSION_STATE.FAILED && <ServiceError />}
{showNoOptionSelectedMessage && (
<ErrorBox
messageTitle={'There is a problem '}
messageLinkBody={'You must select an option'}
errorBoxSummaryId={'error-box-summary'}
errorInputLink={'#delete-docs'}
dataTestId={'delete-error-box'}
/>
)}
<form onSubmit={handleSubmit(submit)}>
<Fieldset id="radio-selection">
<Fieldset.Legend isPageHeading>
Are you sure you want to permanently delete files for:
</Fieldset.Legend>
<div>{patientInfo}</div>
<Radios
id="delete-docs"
error={
showNoOptionSelectedMessage && noOptionSelectedError
}
>
<Radios.Radio
value={DELETE_DOCUMENTS_OPTION.YES}
inputRef={deleteDocsRef}
{...radioProps}
id="yes-radio-button"
data-testid="yes-radio-btn"
>
Yes
</Radios.Radio>
<Radios.Radio
value={DELETE_DOCUMENTS_OPTION.NO}
inputRef={deleteDocsRef}
{...radioProps}
id="no-radio-button"
data-testid="no-radio-btn"
>
No
</Radios.Radio>
</Radios>
</Fieldset>
{deletionStage === SUBMISSION_STATE.PENDING ? (
<SpinnerButton
id="delete-docs-spinner"
status="Deleting..."
disabled={true}
/>
) : (
<Button
type="submit"
id="delete-submit-button"
data-testid="delete-submit-btn"
>
Continue
</Button>
)}
</form>
</>
}
/>
<Route index element={<PageIndexView />} />
<Route
path={getLastURLPath(routeChildren.ARF_DELETE_COMPLETE)}
element={
Expand Down
130 changes: 62 additions & 68 deletions app/src/pages/documentSearchResultsPage/DocumentSearchResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,78 +80,72 @@ function DocumentSearchResultsPage() {
const pageHeader = 'Download electronic health records and attachments';
useTitle({ pageTitle: pageHeader });

const PageIndexView = () => (
<>
<h1 id="download-page-title">{pageHeader}</h1>

{(submissionState === SUBMISSION_STATE.FAILED ||
downloadState === SUBMISSION_STATE.FAILED) && <ServiceError />}

<PatientSummary />

{submissionState === SUBMISSION_STATE.PENDING && (
<ProgressBar status="Loading..."></ProgressBar>
)}

{submissionState === SUBMISSION_STATE.SUCCEEDED && (
<>
{searchResults.length && patientDetails ? (
<>
<DocumentSearchResults searchResults={searchResults} />
<DocumentSearchResultsOptions
nhsNumber={nhsNumber}
downloadState={downloadState}
updateDownloadState={handleUpdateDownloadState}
setIsDeletingDocuments={setIsDeletingDocuments}
/>
</>
) : (
<p>
<strong id="no-files-message">
There are no documents available for this patient.
</strong>
</p>
)}
</>
)}

{downloadState === SUBMISSION_STATE.FAILED && (
<ErrorBox
messageTitle={'There is a problem with the documents'}
messageBody={'An error has occurred while preparing your download'}
errorBoxSummaryId={'error-box-summary'}
/>
)}

{(submissionState === SUBMISSION_STATE.FAILED ||
submissionState === SUBMISSION_STATE.SUCCEEDED) && (
<p>
<Link
id="start-again-link"
to=""
onClick={(e) => {
e.preventDefault();
navigate(routes.START);
}}
>
Start Again
</Link>
</p>
)}
</>
);

return (
<>
<div>
<Routes>
<Route
index
element={
<>
<h1 id="download-page-title">{pageHeader}</h1>

{(submissionState === SUBMISSION_STATE.FAILED ||
downloadState === SUBMISSION_STATE.FAILED) && <ServiceError />}

<PatientSummary />

{submissionState === SUBMISSION_STATE.PENDING && (
<ProgressBar status="Loading..."></ProgressBar>
)}

{submissionState === SUBMISSION_STATE.SUCCEEDED && (
<>
{searchResults.length && patientDetails ? (
<>
<DocumentSearchResults
searchResults={searchResults}
/>
<DocumentSearchResultsOptions
nhsNumber={nhsNumber}
downloadState={downloadState}
updateDownloadState={handleUpdateDownloadState}
setIsDeletingDocuments={setIsDeletingDocuments}
/>
</>
) : (
<p>
<strong id="no-files-message">
There are no documents available for this
patient.
</strong>
</p>
)}
</>
)}

{downloadState === SUBMISSION_STATE.FAILED && (
<ErrorBox
messageTitle={'There is a problem with the documents'}
messageBody={
'An error has occurred while preparing your download'
}
errorBoxSummaryId={'error-box-summary'}
/>
)}

{(submissionState === SUBMISSION_STATE.FAILED ||
submissionState === SUBMISSION_STATE.SUCCEEDED) && (
<p>
<Link
id="start-again-link"
to=""
onClick={(e) => {
e.preventDefault();
navigate(routes.START);
}}
>
Start Again
</Link>
</p>
)}
</>
}
/>
<Route index element={<PageIndexView />} />
<Route
path={getLastURLPath(routeChildren.ARF_DELETE) + '/*'}
element={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ function LloydGeorgeUploadPage() {
const uploadingDocuments = documents.map((doc) => {
const documentMetadata = uploadSession[doc.file.name];
const documentReference = documentMetadata.fields.key;
// const documentReference = "test123"
return {
...doc,
state: DOCUMENT_UPLOAD_STATE.UPLOADING,
Expand Down
6 changes: 4 additions & 2 deletions app/src/types/blocks/lloydGeorgeActions.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { REPOSITORY_ROLE } from '../generic/authRole';
import { routeChildren } from '../generic/routes';
import { routeChildren, routes } from '../generic/routes';
import { LG_RECORD_STAGE } from './lloydGeorgeStages';

export enum RECORD_ACTION {
UPDATE = 0,
DOWNLOAD = 1,
}

type ActionRoute = routeChildren | routes;

export type LGRecordActionLink = {
label: string;
key: string;
stage?: LG_RECORD_STAGE;
href?: unknown;
href?: ActionRoute;
onClick?: () => void;
type: RECORD_ACTION;
unauthorised?: Array<REPOSITORY_ROLE>;
Expand Down

0 comments on commit e4fc991

Please sign in to comment.