11export { } ;
2- // TODO: Refactor this component
32// import React, { useState } from "react";
43// import {
54// BarChart,
@@ -11,37 +10,37 @@ export {};
1110// CartesianGrid,
1211// LabelList,
1312// } from "recharts";
14- //
13+
1514// const colors = {
1615// text: { light: { primary: "#1D2433", secondary: "#595D67" } },
1716// neutral: { 300: "#C5C8D8" },
1817// primary: { 700: "#0C727E" },
1918// success: { 900: "#0D8312" },
2019// };
21- //
20+
2221// interface WeeklyEarningsChartProps {
2322// weeklyEarnings?: number[];
2423// }
25- //
24+
2625// interface ChartDataItem {
2726// amount: number;
2827// day: string;
2928// isToday: boolean;
3029// }
31- //
30+
3231// const WeeklyEarningsChart = ({
3332// weeklyEarnings = [],
3433// }: WeeklyEarningsChartProps) => {
3534// const [selectedBarIndex, setSelectedBarIndex] = useState<number | null>(null);
36- //
35+
3736// // Day labels for the week (Monday = index 0, Sunday = index 6)
3837// const allDayLabels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
39- //
38+
4039// // Calculate which day of the week today is (0 = Monday, 6 = Sunday)
4140// const today = new Date();
4241// const dayOfWeek = today.getDay(); // 0 = Sunday, 1 = Monday, etc.
4342// const todayIndex = dayOfWeek === 0 ? 6 : dayOfWeek - 1; // Convert to 0 = Monday
44- //
43+
4544// // Only show days from Monday up to today
4645// const chartData: ChartDataItem[] = weeklyEarnings
4746// .slice(0, todayIndex + 1) // Only include Monday through today
@@ -50,12 +49,12 @@ export {};
5049// day: allDayLabels[index] || "",
5150// isToday: index === todayIndex,
5251// }));
53- //
52+
5453// // Calculate max earnings from only the days we're showing
5554// const visibleEarnings = weeklyEarnings.slice(0, todayIndex + 1);
5655// const maxEarnings = Math.max(...visibleEarnings.filter((val) => val != null), 0);
5756// const upperBound = Math.ceil(maxEarnings * 1.2) || 10;
58- //
57+
5958// return (
6059// <div
6160// style={{
@@ -78,7 +77,7 @@ export {};
7877// >
7978// Weekly Earnings
8079// </h2>
81- //
80+
8281// <div style={{ height: 200, width: "100%", marginBottom: 16 }}>
8382// <ResponsiveContainer width="100%" height="100%">
8483// <BarChart
@@ -155,5 +154,5 @@ export {};
155154// </div>
156155// );
157156// };
158- //
157+
159158// export default WeeklyEarningsChart;
0 commit comments