2023-05-11 12:08:46 +00:00
|
|
|
// ui
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IDefaultAnalyticsResponse } from "@plane/types";
|
|
|
|
import { BarGraph, ProfileEmptyState } from "@/components/ui";
|
2023-08-18 09:45:33 +00:00
|
|
|
// image
|
|
|
|
import emptyBarGraph from "public/empty-state/empty_bar_graph.svg";
|
2023-05-11 12:08:46 +00:00
|
|
|
// types
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
defaultAnalytics: IDefaultAnalyticsResponse;
|
|
|
|
};
|
|
|
|
|
2023-05-15 05:52:06 +00:00
|
|
|
export const AnalyticsScope: React.FC<Props> = ({ defaultAnalytics }) => (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="rounded-[10px] border border-custom-border-200">
|
2023-05-15 05:52:06 +00:00
|
|
|
<h5 className="p-3 text-xs text-green-500">SCOPE</h5>
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="divide-y divide-custom-border-200">
|
2023-05-15 05:52:06 +00:00
|
|
|
<div>
|
|
|
|
<h6 className="px-3 text-base font-medium">Pending issues</h6>
|
2023-09-22 12:13:23 +00:00
|
|
|
{defaultAnalytics.pending_issue_user && defaultAnalytics.pending_issue_user.length > 0 ? (
|
2023-05-17 07:55:58 +00:00
|
|
|
<BarGraph
|
|
|
|
data={defaultAnalytics.pending_issue_user}
|
2023-09-22 12:13:23 +00:00
|
|
|
indexBy="assignees__id"
|
2023-05-17 07:55:58 +00:00
|
|
|
keys={["count"]}
|
|
|
|
height="250px"
|
|
|
|
colors={() => `#f97316`}
|
2023-11-08 15:01:46 +00:00
|
|
|
customYAxisTickValues={defaultAnalytics.pending_issue_user.map((d) => (d.count > 0 ? d.count : 50))}
|
2023-05-17 07:55:58 +00:00
|
|
|
tooltip={(datum) => {
|
|
|
|
const assignee = defaultAnalytics.pending_issue_user.find(
|
2023-09-22 12:13:23 +00:00
|
|
|
(a) => a.assignees__id === `${datum.indexValue}`
|
2023-05-17 07:55:58 +00:00
|
|
|
);
|
2023-05-15 05:52:06 +00:00
|
|
|
|
2023-05-17 07:55:58 +00:00
|
|
|
return (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="rounded-md border border-custom-border-200 bg-custom-background-80 p-2 text-xs">
|
2023-07-10 07:17:00 +00:00
|
|
|
<span className="font-medium text-custom-text-200">
|
2023-08-08 07:31:43 +00:00
|
|
|
{assignee ? assignee.assignees__display_name : "No assignee"}:{" "}
|
2023-05-17 07:55:58 +00:00
|
|
|
</span>
|
|
|
|
{datum.value}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
axisBottom={{
|
|
|
|
renderTick: (datum) => {
|
2023-09-22 12:13:23 +00:00
|
|
|
const assignee = defaultAnalytics.pending_issue_user[datum.tickIndex] ?? "";
|
2023-05-17 07:55:58 +00:00
|
|
|
|
2023-09-22 12:13:23 +00:00
|
|
|
if (assignee && assignee?.assignees__avatar && assignee?.assignees__avatar !== "")
|
2023-05-17 07:55:58 +00:00
|
|
|
return (
|
|
|
|
<g transform={`translate(${datum.x},${datum.y})`}>
|
|
|
|
<image
|
|
|
|
x={-8}
|
|
|
|
y={10}
|
|
|
|
width={16}
|
|
|
|
height={16}
|
2023-09-22 12:13:23 +00:00
|
|
|
xlinkHref={assignee?.assignees__avatar}
|
2023-05-17 07:55:58 +00:00
|
|
|
style={{ clipPath: "circle(50%)" }}
|
|
|
|
/>
|
|
|
|
</g>
|
|
|
|
);
|
|
|
|
else
|
|
|
|
return (
|
|
|
|
<g transform={`translate(${datum.x},${datum.y})`}>
|
|
|
|
<circle cy={18} r={8} fill="#374151" />
|
|
|
|
<text x={0} y={21} textAnchor="middle" fontSize={9} fill="#ffffff">
|
2023-09-22 12:13:23 +00:00
|
|
|
{datum.value ? `${assignee.assignees__display_name}`.toUpperCase()[0] : "?"}
|
2023-05-17 07:55:58 +00:00
|
|
|
</text>
|
|
|
|
</g>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
margin={{ top: 20 }}
|
|
|
|
theme={{
|
|
|
|
axis: {},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : (
|
2023-08-18 09:45:33 +00:00
|
|
|
<div className="px-7 py-4">
|
|
|
|
<ProfileEmptyState
|
|
|
|
title="No Data yet"
|
|
|
|
description="Analysis of pending issues by co-workers appears here."
|
|
|
|
image={emptyBarGraph}
|
|
|
|
/>
|
2023-05-17 07:55:58 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2023-05-11 12:08:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-15 05:52:06 +00:00
|
|
|
</div>
|
|
|
|
);
|