From 5dba1f3dbb522ea30117ad3a529f4de7a44a4a5d Mon Sep 17 00:00:00 2001 From: Nityananda Gohain Date: Wed, 12 Mar 2025 19:37:54 +0530 Subject: [PATCH] fix: use correct keys in dashboard list (#7283) * fix: use correct keys in dashboard list * fix: use correct keys in dashboard list --- .../ListOfDashboard/DashboardsList.tsx | 24 +++++++------- .../DashboardDescription/index.tsx | 10 +++--- .../hooks/dashboard/useUpdateDashboard.tsx | 2 +- .../mocks-server/__mockdata__/dashboards.ts | 32 +++++++++---------- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/frontend/src/container/ListOfDashboard/DashboardsList.tsx b/frontend/src/container/ListOfDashboard/DashboardsList.tsx index 96fdff7116..af07d16444 100644 --- a/frontend/src/container/ListOfDashboard/DashboardsList.tsx +++ b/frontend/src/container/ListOfDashboard/DashboardsList.tsx @@ -186,16 +186,14 @@ function DashboardsList(): JSX.Element { const sortDashboardsByCreatedAt = (dashboards: Dashboard[]): void => { const sortedDashboards = dashboards.sort( - (a, b) => - new Date(b.created_at).getTime() - new Date(a.created_at).getTime(), + (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), ); setDashboards(sortedDashboards); }; const sortDashboardsByUpdatedAt = (dashboards: Dashboard[]): void => { const sortedDashboards = dashboards.sort( - (a, b) => - new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime(), + (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(), ); setDashboards(sortedDashboards); }; @@ -260,16 +258,16 @@ function DashboardsList(): JSX.Element { const data: Data[] = dashboards?.map((e) => ({ - createdAt: e.created_at, + createdAt: e.createdAt, description: e.data.description || '', id: e.uuid, - lastUpdatedTime: e.updated_at, + lastUpdatedTime: e.updatedAt, name: e.data.title, tags: e.data.tags || [], key: e.uuid, - createdBy: e.created_by, + createdBy: e.createdBy, isLocked: !!e.isLocked || false, - lastUpdatedBy: e.updated_by, + lastUpdatedBy: e.updatedBy, image: e.data.image || Base64Icons[0], variables: e.data.variables, widgets: e.data.widgets, @@ -978,10 +976,10 @@ function DashboardsList(): JSX.Element { {visibleColumns.createdBy && (
- {dashboards?.[0]?.created_by?.substring(0, 1).toUpperCase()} + {dashboards?.[0]?.createdBy?.substring(0, 1).toUpperCase()} - {dashboards?.[0]?.created_by} + {dashboards?.[0]?.createdBy}
)} @@ -990,16 +988,16 @@ function DashboardsList(): JSX.Element { {visibleColumns.updatedAt && ( - {onLastUpdated(dashboards?.[0]?.updated_at || '')} + {onLastUpdated(dashboards?.[0]?.updatedAt || '')} )} {visibleColumns.updatedBy && (
- {dashboards?.[0]?.updated_by?.substring(0, 1).toUpperCase()} + {dashboards?.[0]?.updatedBy?.substring(0, 1).toUpperCase()} - {dashboards?.[0]?.updated_by} + {dashboards?.[0]?.updatedBy}
)} diff --git a/frontend/src/container/NewDashboard/DashboardDescription/index.tsx b/frontend/src/container/NewDashboard/DashboardDescription/index.tsx index 8e116522be..cf7263d04e 100644 --- a/frontend/src/container/NewDashboard/DashboardDescription/index.tsx +++ b/frontend/src/container/NewDashboard/DashboardDescription/index.tsx @@ -140,7 +140,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element { let isAuthor = false; if (selectedDashboard && user && user.email) { - isAuthor = selectedDashboard?.created_by === user?.email; + isAuthor = selectedDashboard?.createdBy === user?.email; } let permissions: ComponentTypes[] = ['add_panel']; @@ -152,7 +152,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element { const { notifications } = useNotifications(); const userRole: ROLES | null = - selectedDashboard?.created_by === user?.email + selectedDashboard?.createdBy === user?.email ? (USER_ROLES.AUTHOR as ROLES) : user.role; @@ -364,14 +364,14 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element { {(isAuthor || user.role === USER_ROLES.ADMIN) && (