// nivo import { BarDatum } from "@nivo/bar"; // icons import { getPriorityIcon } from "components/icons"; // helpers import { addSpaceIfCamelCase } from "helpers/string.helper"; // helpers import { generateBarColor, renderMonthAndYear } from "helpers/analytics.helper"; // types import { IAnalyticsParams, IAnalyticsResponse } from "types"; // constants import { ANALYTICS_X_AXIS_VALUES, ANALYTICS_Y_AXIS_VALUES, DATE_KEYS } from "constants/analytics"; type Props = { analytics: IAnalyticsResponse; barGraphData: { data: BarDatum[]; xAxisKeys: string[]; }; params: IAnalyticsParams; yAxisKey: "count" | "estimate"; }; export const AnalyticsTable: React.FC = ({ analytics, barGraphData, params, yAxisKey }) => (
{params.segment ? ( barGraphData.xAxisKeys.map((key) => ( )) ) : ( )} {barGraphData.data.map((item, index) => ( {params.segment ? ( barGraphData.xAxisKeys.map((key, index) => ( )) ) : ( )} ))}
{ANALYTICS_X_AXIS_VALUES.find((v) => v.value === params.x_axis)?.label}
{params.segment === "priority" ? ( getPriorityIcon(key) ) : ( )} {DATE_KEYS.includes(params.segment ?? "") ? renderMonthAndYear(key) : key}
{ANALYTICS_Y_AXIS_VALUES.find((v) => v.value === params.y_axis)?.label}
{params.x_axis === "priority" ? ( getPriorityIcon(`${item.name}`) ) : ( )} {addSpaceIfCamelCase(`${item.name}`)} {item[key] ?? 0} {item[yAxisKey]}
);