From 98f35dd2b3da7bb23ec59a93293ce8d47c041606 Mon Sep 17 00:00:00 2001 From: okorie2 Date: Tue, 14 Nov 2023 13:47:31 +0100 Subject: [PATCH] feat:DX-848; show updated chart in report on first load --- .../common/subheader-toolbar/SubheaderToolbar.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx b/src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx index f56b78615..a8067fb2e 100644 --- a/src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx +++ b/src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx @@ -189,11 +189,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) { }; React.useEffect(() => { - //completes chart creation, returns back to persisted report view if ( (editChartSuccess || createChartSuccess) && createChartFromReport.state ) { + //returns back to persisted report view setCreateChartFromReport({ ...createChartFromReport, state: false, @@ -206,11 +206,16 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) { `/report/${createChartFromReport.page}/${createChartFromReport.view}` ); } - } else if (editChartSuccess && !createChartFromReport.state) { - history.push(`/chart/${page}`); } }, [editChartSuccess, createChartSuccess]); + React.useEffect(() => { + if (editChartSuccess && createChartFromReport.view === "") { + console.log(createChartFromReport.state, "state"); + history.push(`/chart/${page}`); + } + }, [editChartSuccess]); + React.useEffect(() => { return () => { createChartClear();