diff --git a/app/package-lock.json b/app/package-lock.json index c1513a074..6ffcc11a8 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -28,6 +28,7 @@ "sass": "^1.66.1", "serve": "^14.2.1", "typescript": "^4.9.5", + "usehooks-ts": "^2.9.1", "util": "^0.12.5", "web-vitals": "^2.1.4" }, @@ -25545,6 +25546,19 @@ } } }, + "node_modules/usehooks-ts": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-2.9.1.tgz", + "integrity": "sha512-2FAuSIGHlY+apM9FVlj8/oNhd+1y+Uwv5QNkMQz1oSfdHk4PXo1qoCw9I5M7j0vpH8CSWFJwXbVPeYDjLCx9PA==", + "engines": { + "node": ">=16.15.0", + "npm": ">=8" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", diff --git a/app/package.json b/app/package.json index 7ab7a58ec..ad1176198 100644 --- a/app/package.json +++ b/app/package.json @@ -35,6 +35,7 @@ "sass": "^1.66.1", "serve": "^14.2.1", "typescript": "^4.9.5", + "usehooks-ts": "^2.9.1", "util": "^0.12.5", "web-vitals": "^2.1.4" }, diff --git a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx index 6c251577c..9c09bad57 100644 --- a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx +++ b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx @@ -8,9 +8,17 @@ import PdfViewer from '../../components/generic/pdfViewer/PdfViewer'; import { DOWNLOAD_STAGE } from '../../types/generic/downloadStage'; import formatFileSize from '../../helpers/utils/formatFileSize'; import useBaseAPIHeaders from '../../helpers/hooks/useBaseAPIHeaders'; +import { useOnClickOutside } from 'usehooks-ts'; +import { ReactComponent as Chevron } from '../../styles/down-chevron.svg'; +import { Link } from 'react-router-dom'; import { getFormattedDatetime } from '../../helpers/utils/formatDatetime'; import getLloydGeorgeRecord from '../../helpers/requests/getLloydGeorgeRecord'; +enum LG_RECORD_STAGE { + RECORD = 0, + DOWNLOAD_ALL = 1, +} + function LloydGeorgeRecordPage() { const [patientDetails] = usePatientDetailsContext(); const [downloadStage, setDownloadStage] = useState(DOWNLOAD_STAGE.INITIAL); @@ -23,6 +31,13 @@ function LloydGeorgeRecordPage() { const baseUrl = useBaseAPIUrl(); const baseHeaders = useBaseAPIHeaders(); const mounted = useRef(false); + const actionsRef = useRef(null); + const [showActionsMenu, setShowActionsMenu] = useState(false); + const [stage, setStage] = useState(LG_RECORD_STAGE.RECORD); + + useOnClickOutside(actionsRef, (e) => { + setShowActionsMenu(false); + }); const dob: String = patientDetails?.birthDate ? getFormattedDate(new Date(patientDetails.birthDate)) @@ -83,27 +98,83 @@ function LloydGeorgeRecordPage() { setNumberOfFiles, setTotalFileSizeInByte, ]); + const handleMoreActions = () => { + setShowActionsMenu(!showActionsMenu); + }; + + const downloadAllHandler = () => { + setStage(LG_RECORD_STAGE.DOWNLOAD_ALL); + }; - const pdfCardDescription = ( + const actionLinks = [ + { label: 'See all files', handler: () => null }, + { label: 'Download all files', handler: downloadAllHandler }, + { label: 'Delete a selection of files', handler: () => null }, + { label: 'Delete file', handler: () => null }, + ]; + + const PdfCardDetails = () => ( <> - Last updated: {lastUpdated} - - {numberOfFiles} files | File size: {formatFileSize(totalFileSizeInByte)} | File - format: PDF - +
+
Last updated: {lastUpdated}
+
+ {numberOfFiles} files | File size: {formatFileSize(totalFileSizeInByte)} | File + format: PDF +
+
+
+
+
+ Select an action... + +
+ {showActionsMenu && ( +
+ + +
    + {actionLinks.map((link, i) => ( +
  1. + { + e.preventDefault(); + link.handler(); + }} + > + {link.label} + +
  2. + ))} +
+
+
+
+ )} +
); - const displayPdfCardDescription = () => { + const PdfCardDescription = () => { if (downloadStage === DOWNLOAD_STAGE.SUCCEEDED) { - return pdfCardDescription; + return ; } else if (downloadStage === DOWNLOAD_STAGE.FAILED) { - return 'No documents are available'; + return No documents are available; } else { - return 'Loading...'; + return Loading...; } }; - return ( + const RecordStage = () => ( <> {fullScreen && ( - + Lloyd George record - - {displayPdfCardDescription()} - + {downloadStage === DOWNLOAD_STAGE.SUCCEEDED && ( @@ -162,6 +231,20 @@ function LloydGeorgeRecordPage() { )} ); + const DownloadAllStage = () => ( + <> +

Downloading documents

+

Alex Cool Bloggs

+

NHS number: 1428571428

+ + ); + + switch (stage) { + case LG_RECORD_STAGE.RECORD: + return ; + case LG_RECORD_STAGE.DOWNLOAD_ALL: + return ; + } } export default LloydGeorgeRecordPage; diff --git a/app/src/styles/App.scss b/app/src/styles/App.scss index bb301c828..2a84fc1b1 100644 --- a/app/src/styles/App.scss +++ b/app/src/styles/App.scss @@ -115,6 +115,71 @@ font-size: 24px; } +.lg-actions { + position: absolute; + top: 32px; + right: 32px; + &-select { + border-color: #000; + position: relative; + box-sizing: border-box; + border: none; + padding: 0; + width: 182.5px; + @media (max-width: 640px) { + width: 161.5px; + } + @media (max-width: 480px) { + display: none; + } + &_border { + border: solid black 2px; + width: 100%; + height: 100%; + &--selected { + border-width: 4px; + } + } + &:focus, + &:active, + &--selected { + box-shadow: 0px 0px 0px 4px #ffeb3b; + } + &_placeholder { + position: absolute; + top: 50%; + transform: translateY(-50%); + left: 10px; + box-sizing: border-box; + } + &_icon { + height: 9px; + width: auto; + position: absolute; + top: 50%; + transform: translateY(-50%); + right: 5px; + box-sizing: border-box; + } + + cursor: pointer; + } + &-menu { + position: absolute; + right: 0px; + z-index: 1000; + width: 252.5px; + box-shadow: 0 10px 10px rgba(0, 0, 0, 0.3); + ol { + padding-left: 0; + li { + font-size: 16px; + list-style-type: none; + } + } + } +} + @-moz-document url-prefix() { #pdf-viewer { margin-top: 6px; diff --git a/app/src/styles/down-chevron.svg b/app/src/styles/down-chevron.svg new file mode 100644 index 000000000..1781fb49f --- /dev/null +++ b/app/src/styles/down-chevron.svg @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file