2023-05-11 12:08:46 +00:00
|
|
|
// ui
|
2024-05-15 13:13:07 +00:00
|
|
|
import { IDefaultAnalyticsUser } from "@plane/types";
|
2024-03-19 14:38:35 +00:00
|
|
|
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 = {
|
2024-05-15 13:13:07 +00:00
|
|
|
pendingUnAssignedIssues: IDefaultAnalyticsUser[];
|
|
|
|
pendingAssignedIssues: IDefaultAnalyticsUser[];
|
2023-05-11 12:08:46 +00:00
|
|
|
};
|
|
|
|
|
2024-05-15 13:13:07 +00:00
|
|
|
export const AnalyticsScope: React.FC<Props> = ({ pendingUnAssignedIssues, pendingAssignedIssues }) => (
|
|
|
|
<div className="rounded-[10px] border border-custom-border-200 p-3">
|
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>
|
2024-05-15 13:13:07 +00:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
<h6 className=" text-base font-medium">Pending issues</h6>
|
|
|
|
<div className="relative flex items-center py-1 px-3 rounded-md gap-2 text-xs text-custom-primary-100 bg-custom-primary-100/10">
|
|
|
|
Unassigned: {pendingUnAssignedIssues.length}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{pendingAssignedIssues && pendingAssignedIssues.length > 0 ? (
|
2023-05-17 07:55:58 +00:00
|
|
|
<BarGraph
|
2024-05-15 13:13:07 +00:00
|
|
|
data={pendingAssignedIssues}
|
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`}
|
2024-05-15 13:13:07 +00:00
|
|
|
customYAxisTickValues={pendingAssignedIssues.map((d) => (d.count > 0 ? d.count : 50))}
|
2023-05-17 07:55:58 +00:00
|
|
|
tooltip={(datum) => {
|
2024-05-15 13:13:07 +00:00
|
|
|
const assignee = pendingAssignedIssues.find((a) => a.assignees__id === `${datum.indexValue}`);
|
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) => {
|
2024-05-15 13:13:07 +00:00
|
|
|
const assignee = pendingAssignedIssues[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>
|
|
|
|
);
|