import { useState } from "react"; // recharts import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; // ui import { CustomMenu } from "components/ui"; // types import { IIssue } from "types"; // constants import { MONTHS } from "constants/project"; type Props = { issues: IIssue[] | undefined; }; export const CompletedIssuesGraph: React.FC = ({ issues }) => { const [month, setMonth] = useState(new Date().getMonth()); const weeks = month === 1 ? 4 : 5; const monthIssues = issues?.filter( (i) => new Date(i.created_at).getMonth() === month && new Date(i.created_at).getFullYear() === new Date().getFullYear() ) ?? []; const data: any[] = []; for (let j = 1; j <= weeks; j++) { const weekIssues = monthIssues.filter( (i) => i.completed_at && Math.ceil(new Date(i.completed_at).getDate() / 7) === j ); data.push({ name: `Week ${j}`, completedIssues: weekIssues.length }); } return (

Issues closed by you

{MONTHS[month]}} noBorder> {MONTHS.map((month, index) => ( setMonth(index)}> {month} ))}
); };