From 9a8ff4a11f3c8d8b0f3e802feaac17d38aab507f Mon Sep 17 00:00:00 2001 From: Steph Torres Date: Mon, 28 Oct 2024 11:58:37 +0000 Subject: [PATCH] [PMRP-1035] add resetDocStage to RecordCard, stop reusing old cloudfront URL on fullscreen toggle --- .../LloydGeorgeViewRecordStage.test.tsx | 1 + .../LloydGeorgeViewRecordStage.tsx | 5 +++++ app/src/components/generic/recordCard/RecordCard.test.tsx | 1 + app/src/components/generic/recordCard/RecordCard.tsx | 3 +++ .../pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx | 1 + 5 files changed, 11 insertions(+) diff --git a/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.test.tsx b/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.test.tsx index b81182993..89fd125f1 100644 --- a/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.test.tsx +++ b/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.test.tsx @@ -450,6 +450,7 @@ const renderComponent = (propsOverride?: Partial) => { refreshRecord: jest.fn(), cloudFrontUrl: 'http://test.com', showMenu: true, + resetDocState: jest.fn(), ...propsOverride, }; render(); diff --git a/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.tsx b/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.tsx index 0d42e19e6..f2a30f319 100644 --- a/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.tsx +++ b/app/src/components/blocks/_lloydGeorge/lloydGeorgeViewRecordStage/LloydGeorgeViewRecordStage.tsx @@ -41,6 +41,7 @@ export type Props = { refreshRecord: () => void; cloudFrontUrl: string; showMenu: boolean; + resetDocState: () => void; }; function LloydGeorgeViewRecordStage({ @@ -52,6 +53,7 @@ function LloydGeorgeViewRecordStage({ refreshRecord, cloudFrontUrl, showMenu, + resetDocState, }: Props) { const navigate = useNavigate(); const [fullScreen, setFullScreen] = useState(false); @@ -121,6 +123,7 @@ function LloydGeorgeViewRecordStage({ onClick={(e) => { e.preventDefault(); setFullScreen(false); + resetDocState(); }} > Exit full screen @@ -228,6 +231,7 @@ function LloydGeorgeViewRecordStage({ isFullScreen={fullScreen} refreshRecord={refreshRecord} cloudFrontUrl={cloudFrontUrl} + resetDocStage={resetDocState} /> @@ -240,6 +244,7 @@ function LloydGeorgeViewRecordStage({ isFullScreen={fullScreen} refreshRecord={refreshRecord} cloudFrontUrl={cloudFrontUrl} + resetDocStage={resetDocState} /> )} diff --git a/app/src/components/generic/recordCard/RecordCard.test.tsx b/app/src/components/generic/recordCard/RecordCard.test.tsx index c0d79ad9a..da2c89571 100644 --- a/app/src/components/generic/recordCard/RecordCard.test.tsx +++ b/app/src/components/generic/recordCard/RecordCard.test.tsx @@ -43,6 +43,7 @@ describe('RecordCard Component', () => { isFullScreen: false, refreshRecord: jest.fn(), cloudFrontUrl: 'https://test.com', + resetDocStage: jest.fn(), }; beforeEach(() => { diff --git a/app/src/components/generic/recordCard/RecordCard.tsx b/app/src/components/generic/recordCard/RecordCard.tsx index f5c7f7b48..20bb963ce 100644 --- a/app/src/components/generic/recordCard/RecordCard.tsx +++ b/app/src/components/generic/recordCard/RecordCard.tsx @@ -11,6 +11,7 @@ export type Props = { isFullScreen: boolean; refreshRecord: () => void; cloudFrontUrl: string; + resetDocStage: () => void; }; function RecordCard({ @@ -20,6 +21,7 @@ function RecordCard({ isFullScreen, cloudFrontUrl, refreshRecord, + resetDocStage, }: Props) { const role = useRole(); const userIsGpClinical = role === REPOSITORY_ROLE.GP_CLINICAL; @@ -63,6 +65,7 @@ function RecordCard({ data-testid="full-screen-btn" onClick={() => { fullScreenHandler(true); + resetDocStage(); }} > View in full screen diff --git a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx index b99f368de..206134ad0 100644 --- a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx +++ b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.tsx @@ -125,6 +125,7 @@ function LloydGeorgeRecordPage() { refreshRecord={refreshRecord} cloudFrontUrl={cloudFrontUrl} showMenu={showMenu} + resetDocState={resetDocState} /> } />