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 - +