fix: assignee name in analytics tooltip (#1081)

This commit is contained in:
Aaryan Khandelwal 2023-05-19 17:08:32 +05:30 committed by GitHub
parent e162c88f03
commit f2c8bdba34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -3,19 +3,28 @@ import { BarTooltipProps } from "@nivo/bar";
import { DATE_KEYS } from "constants/analytics"; import { DATE_KEYS } from "constants/analytics";
import { renderMonthAndYear } from "helpers/analytics.helper"; import { renderMonthAndYear } from "helpers/analytics.helper";
// types // types
import { IAnalyticsParams } from "types"; import { IAnalyticsParams, IAnalyticsResponse } from "types";
type Props = { type Props = {
datum: BarTooltipProps<any>; datum: BarTooltipProps<any>;
analytics: IAnalyticsResponse;
params: IAnalyticsParams; params: IAnalyticsParams;
}; };
export const CustomTooltip: React.FC<Props> = ({ datum, params }) => { export const CustomTooltip: React.FC<Props> = ({ datum, analytics, params }) => {
let tooltipValue: string | number = ""; let tooltipValue: string | number = "";
if (params.segment) { if (params.segment) {
if (DATE_KEYS.includes(params.segment)) tooltipValue = renderMonthAndYear(datum.id); 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 { } else {
if (DATE_KEYS.includes(params.x_axis)) tooltipValue = datum.indexValue; if (DATE_KEYS.includes(params.x_axis)) tooltipValue = datum.indexValue;
else tooltipValue = datum.id === "count" ? "Issue count" : "Estimate"; else tooltipValue = datum.id === "count" ? "Issue count" : "Estimate";

View File

@ -66,7 +66,7 @@ export const AnalyticsGraph: React.FC<Props> = ({
) )
} }
customYAxisTickValues={generateYAxisTickValues()} customYAxisTickValues={generateYAxisTickValues()}
tooltip={(datum) => <CustomTooltip datum={datum} params={params} />} tooltip={(datum) => <CustomTooltip datum={datum} analytics={analytics} params={params} />}
height={fullScreen ? "400px" : "300px"} height={fullScreen ? "400px" : "300px"}
margin={{ margin={{
right: 20, right: 20,