From 1e33f16943c1df3b6e45a1479f56e33a98f5a7bd Mon Sep 17 00:00:00 2001 From: Pranay Kumar Date: Fri, 22 Oct 2021 17:07:22 +0530 Subject: [PATCH] refactor: dashboard route generation (#340) * refactor: dashboard route generation * fix: dashboard link --- .../ListOfDashboard/TableComponents/Name.tsx | 11 +++++++---- frontend/src/container/ListOfDashboard/index.tsx | 9 ++++++--- frontend/src/container/NewWidget/index.tsx | 4 ++-- frontend/src/lib/updateUrl.ts | 9 --------- frontend/src/pages/DashboardWidget/index.tsx | 10 +++++++--- frontend/src/store/actions/dashboard/saveDashboard.ts | 4 ++-- 6 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 frontend/src/lib/updateUrl.ts diff --git a/frontend/src/container/ListOfDashboard/TableComponents/Name.tsx b/frontend/src/container/ListOfDashboard/TableComponents/Name.tsx index 80787ff18e..451b6d0553 100644 --- a/frontend/src/container/ListOfDashboard/TableComponents/Name.tsx +++ b/frontend/src/container/ListOfDashboard/TableComponents/Name.tsx @@ -1,8 +1,7 @@ import { Button } from 'antd'; import ROUTES from 'constants/routes'; -import updateUrl from 'lib/updateUrl'; import React, { useCallback } from 'react'; -import { useHistory } from 'react-router-dom'; +import { generatePath, useHistory } from 'react-router-dom'; import { Data } from '..'; @@ -10,8 +9,12 @@ const Name = (name: Data['name'], data: Data): JSX.Element => { const { push } = useHistory(); const onClickHandler = useCallback(() => { - push(updateUrl(ROUTES.DASHBOARD, ':dashboardId', data.id)); - }, []); + push( + generatePath(ROUTES.DASHBOARD, { + dashboardId: data.id, + }), + ); + }, [data.id, push]); return (