Skip to content

Commit

Permalink
feat:DX-848; show updated chart in report on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
okorie2 committed Nov 13, 2023
1 parent ae142e2 commit 997a47b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,14 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
values: chart,
});
}
};

React.useEffect(() => {
//completes chart creation, returns back to persisted report view
if (createChartFromReport.state) {
if (
(editChartSuccess || createChartSuccess) &&
createChartFromReport.state
) {
setCreateChartFromReport({
...createChartFromReport,
state: false,
Expand All @@ -201,8 +206,10 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
`/report/${createChartFromReport.page}/${createChartFromReport.view}`
);
}
} else if (editChartSuccess && !createChartFromReport.state) {
history.push(`/chart/${page}`);
}
};
}, [editChartSuccess, createChartSuccess]);

React.useEffect(() => {
return () => {
Expand Down Expand Up @@ -244,9 +251,9 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
setShowSnackbar(
createChartSuccess ? `Chart created successfully!` : null
);
const id = createChartSuccess ? createChartData.id : page;
const chartId = createChartSuccess ? createChartData.id : page;
if (createChartFromReport.view === "") {
history.push(`/chart/${id}`);
history.push(`/chart/${chartId}`);
}
}
}, [createChartSuccess, createChartData]);
Expand Down

0 comments on commit 997a47b

Please sign in to comment.