From f2c8bdba34306bdf9c41e8c4df7a798fe5c79575 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Fri, 19 May 2023 17:08:32 +0530 Subject: [PATCH] fix: assignee name in analytics tooltip (#1081) --- .../custom-analytics/graph/custom-tooltip.tsx | 15 ++++++++++++--- .../analytics/custom-analytics/graph/index.tsx | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/app/components/analytics/custom-analytics/graph/custom-tooltip.tsx b/apps/app/components/analytics/custom-analytics/graph/custom-tooltip.tsx index d288ae3a9..7fd0c1396 100644 --- a/apps/app/components/analytics/custom-analytics/graph/custom-tooltip.tsx +++ b/apps/app/components/analytics/custom-analytics/graph/custom-tooltip.tsx @@ -3,19 +3,28 @@ import { BarTooltipProps } from "@nivo/bar"; import { DATE_KEYS } from "constants/analytics"; import { renderMonthAndYear } from "helpers/analytics.helper"; // types -import { IAnalyticsParams } from "types"; +import { IAnalyticsParams, IAnalyticsResponse } from "types"; type Props = { datum: BarTooltipProps; + analytics: IAnalyticsResponse; params: IAnalyticsParams; }; -export const CustomTooltip: React.FC = ({ datum, params }) => { +export const CustomTooltip: React.FC = ({ datum, analytics, params }) => { let tooltipValue: string | number = ""; if (params.segment) { if (DATE_KEYS.includes(params.segment)) tooltipValue = renderMonthAndYear(datum.id); - else tooltipValue = datum.id; + else if (params.segment === "assignees__email") { + const assignee = analytics.extras.assignee_details.find( + (a) => a.assignees__email === datum.id + ); + + if (assignee) + tooltipValue = assignee.assignees__first_name + " " + assignee.assignees__last_name; + else tooltipValue = "No assignees"; + } else tooltipValue = datum.id; } else { if (DATE_KEYS.includes(params.x_axis)) tooltipValue = datum.indexValue; else tooltipValue = datum.id === "count" ? "Issue count" : "Estimate"; diff --git a/apps/app/components/analytics/custom-analytics/graph/index.tsx b/apps/app/components/analytics/custom-analytics/graph/index.tsx index 42bf5f702..cce93204c 100644 --- a/apps/app/components/analytics/custom-analytics/graph/index.tsx +++ b/apps/app/components/analytics/custom-analytics/graph/index.tsx @@ -66,7 +66,7 @@ export const AnalyticsGraph: React.FC = ({ ) } customYAxisTickValues={generateYAxisTickValues()} - tooltip={(datum) => } + tooltip={(datum) => } height={fullScreen ? "400px" : "300px"} margin={{ right: 20,