Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"private": true,
"type": "module",
"dependencies": {
"@apollo/client": "^4.0.9",
"@apollo/client": "^4.1.6",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-toggle-group": "^1.1.11",
"@radix-ui/themes": "^3.3.0",
"dayjs": "^1.11.19",
"firebase": "^12.6.0",
"framer-motion": "^12.23.24",
"graphql": "^16.12.0",
"jotai": "^2.15.1",
"firebase": "^12.9.0",
"framer-motion": "^12.34.3",
"graphql": "^16.13.0",
"jotai": "^2.18.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-firebaseui": "^6.0.0",
"react-router": "^7.13.0",
"react-router-dom": "^7.13.0",
"react-router": "^7.13.1",
"react-router-dom": "^7.13.1",
"react-snowfall": "^2.4.0",
"react-spring": "^10.0.3",
"recharts": "^2.5.14",
"styled-components": "^6.3.10",
"swiper": "^12.0.3",
"recharts": "^3.7.0",
"styled-components": "^6.3.11",
"swiper": "^12.1.2",
"uuid": "^13.0.0"
},
"scripts": {
Expand All @@ -39,41 +39,41 @@
"gen-gql-model": "graphql-codegen"
},
"devDependencies": {
"@babel/preset-env": "^7.28.5",
"@babel/preset-env": "^7.29.0",
"@babel/preset-react": "^7.28.5",
"@babel/preset-typescript": "^7.28.5",
"@eslint/compat": "^2.0.0",
"@graphql-codegen/cli": "^6.1.0",
"@eslint/compat": "^2.0.2",
"@graphql-codegen/cli": "^6.1.2",
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.0",
"@testing-library/react": "^16.3.2",
"@types/jest": "^30.0.0",
"@types/node": "^24.10.1",
"@types/react": "^19.2.6",
"@types/node": "^25.3.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.36",
"@types/uuid": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^8.47.0",
"@typescript-eslint/parser": "^8.47.0",
"@vitejs/plugin-react": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^8.56.1",
"@typescript-eslint/parser": "^8.56.1",
"@vitejs/plugin-react": "^5.1.4",
"babel-jest": "^30.2.0",
"eslint": "^9.39.1",
"eslint": "^10.0.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"globals": "^16.5.0",
"globals": "^17.3.0",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"prettier": "^3.6.2",
"react-test-renderer": "^19.2.0",
"release-it": "^19.0.6",
"sass": "^1.94.2",
"prettier": "^3.8.1",
"react-test-renderer": "^19.2.4",
"release-it": "^19.2.4",
"sass": "^1.97.3",
"typescript": "^5.9.3",
"vercel": "^48.10.10",
"vite": "^7.2.4",
"vite-plugin-pwa": "^1.1.0",
"vercel": "^50.23.2",
"vite": "^7.3.1",
"vite-plugin-pwa": "^1.2.0",
"vite-plugin-svgr": "^4.5.0"
},
"browserslist": {
Expand Down
3 changes: 0 additions & 3 deletions src/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import { BackToHomeParam, useBackToHome } from "./Layout";
import { useAtom, useAtomValue } from "jotai";
import AnimatedPage from "./AnimatedPage";
import { Navigation, Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";

interface CurrentValue {
accountIdx: number;
Expand Down
6 changes: 4 additions & 2 deletions src/components/bases/MonthYearSwiper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from "styled-components";
import { Swiper, SwiperSlide } from "swiper/react";
import { Swiper as SwiperClass } from "swiper/types";
import { Navigation } from "swiper/modules";
import { Text } from "@radix-ui/themes";
import dayjs from "../../lib/dayjs";

Expand All @@ -18,10 +19,11 @@ const MonthYearSwiper: React.FC<MonthYearSwiperProps> = (props) => {
<Swiper
dir="rtl"
spaceBetween={10}
slidesPerView={"auto"}
slidesPerView="auto"
centeredSlides={true}
navigation={true}
onSlideChange={props.onSlideChange}>
onSlideChange={props.onSlideChange}
modules={[Navigation]}>
{props.monthYearList.length === 0 ? (
<MonthYear>
<Text size="6">No data</Text>
Expand Down
9 changes: 7 additions & 2 deletions src/components/report/BarChartReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ const BarChartReport: React.FC<BarChartReportProps> = (props) => {
<YAxis />
<Tooltip />
<Legend align="center" />
<Bar dataKey="income" fill={INCOME_COLOR} name="Income" />
<Bar dataKey="expense" fill={EXPENSE_COLOR} name="Expense" />
<Bar dataKey="income" fill={INCOME_COLOR} name="Income" radius={[8, 8, 0, 0]} />
<Bar
dataKey="expense"
fill={EXPENSE_COLOR}
name="Expense"
radius={[8, 8, 0, 0]}
/>
</BarChart>
</ResponsiveContainer>
</>
Expand Down
123 changes: 63 additions & 60 deletions src/components/report/PieChartReport.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { Cell, Pie, PieChart, ResponsiveContainer, Sector } from "recharts";
import { Cell, Pie, PieChart, PieSectorShapeProps, ResponsiveContainer, Sector } from "recharts";
import styled from "styled-components";
import { currencyState } from "../../common/shareState";
import { formatNumber, groupBy } from "../../common/utils";
Expand All @@ -8,6 +8,7 @@ import BalanceWithCurrency from "../bases/BalanceWithCurrency";
import { EXPENSE_COLOR, INCOME_COLOR, expenseFilter, incomeFilter } from "./reportHelper";
import { Text, Flex } from "@radix-ui/themes";
import { useAtomValue } from "jotai";
import { render } from "@testing-library/react";

interface PieChartReportProps {
transactions: Transaction[];
Expand All @@ -26,7 +27,6 @@ const TotalAmountFlex = styled(Flex)<{ $isExpense: boolean }>`

const PieChartReport: React.FC<PieChartReportProps> = (props) => {
const currency = useAtomValue(currencyState);
const [activeIndex, setActiveIndex] = useState<number>(0);
const [pieChartData, setPieChartData] = useState<PieChartData[]>([]);

const getPieChartData = (transactions: Transaction[], isExpense: boolean): PieChartData[] => {
Expand Down Expand Up @@ -63,7 +63,8 @@ const PieChartReport: React.FC<PieChartReportProps> = (props) => {
},
];
};
const renderActiveShape = (props: any) => {

const renderShape = (props: PieSectorShapeProps) => {
const RADIAN = Math.PI / 180;
const {
cx,
Expand All @@ -77,6 +78,7 @@ const PieChartReport: React.FC<PieChartReportProps> = (props) => {
payload,
percent,
value,
isActive,
} = props;
const sin = Math.sin(-RADIAN * midAngle);
const cos = Math.cos(-RADIAN * midAngle);
Expand All @@ -87,61 +89,64 @@ const PieChartReport: React.FC<PieChartReportProps> = (props) => {
const ex = mx + (cos >= 0 ? 1 : -1) * 10;
const ey = my;
const textAnchor = cos >= 0 ? "start" : "end";
const baseSector = (
<Sector
cx={cx}
cy={cy}
innerRadius={innerRadius}
outerRadius={outerRadius}
startAngle={startAngle}
endAngle={endAngle}
fill={fill}
/>
);

return (
<g>
<text x={cx} y={cy} dy={8} textAnchor="middle" fill={fill} fontSize="10px">
{payload.name}
</text>
<Sector
cx={cx}
cy={cy}
innerRadius={innerRadius}
outerRadius={outerRadius}
startAngle={startAngle}
endAngle={endAngle}
fill={fill}
/>
if (isActive) {
return (
<g>
<text x={cx} y={cy} dy={8} textAnchor="middle" fill={fill} fontSize="10px">
{payload.name}
</text>
{baseSector}
{payload.name !== "No data" ? (
<>
<Sector
cx={cx}
cy={cy}
startAngle={startAngle}
endAngle={endAngle}
innerRadius={outerRadius + 6}
outerRadius={outerRadius + 10}
fill={fill}
/>
<path
d={`M${sx},${sy}L${mx},${my}L${ex},${ey}`}
stroke={fill}
fill="none"
/>
<circle cx={ex} cy={ey} r={2} fill={fill} stroke="none" />
<text
x={ex + (cos >= 0 ? 1 : -1) * 12}
y={ey}
textAnchor={textAnchor}
fill="#333"
fontSize="10px">{`${currency} ${formatNumber(value, 1)}`}</text>
<text
x={ex + (cos >= 0 ? 1 : -1) * 12}
y={ey}
dy={18}
textAnchor={textAnchor}
fill="#999"
fontSize="8px">
{`(${(percent * 100).toFixed(1)}%)`}
</text>
</>
) : null}
</g>
);
}

{payload.name !== "No data" ? (
<>
<Sector
cx={cx}
cy={cy}
startAngle={startAngle}
endAngle={endAngle}
innerRadius={outerRadius + 6}
outerRadius={outerRadius + 10}
fill={fill}
/>
<path
d={`M${sx},${sy}L${mx},${my}L${ex},${ey}`}
stroke={fill}
fill="none"
/>
<circle cx={ex} cy={ey} r={2} fill={fill} stroke="none" />
<text
x={ex + (cos >= 0 ? 1 : -1) * 12}
y={ey}
textAnchor={textAnchor}
fill="#333"
fontSize="10px">{`${currency} ${formatNumber(value, 1)}`}</text>
<text
x={ex + (cos >= 0 ? 1 : -1) * 12}
y={ey}
dy={18}
textAnchor={textAnchor}
fill="#999"
fontSize="8px">
{`(${(percent * 100).toFixed(1)}%)`}
</text>
</>
) : null}
</g>
);
};
const onPieEnter = (_: any, index: number) => {
setActiveIndex(index);
return baseSector;
};

useEffect(() => {
Expand Down Expand Up @@ -171,15 +176,13 @@ const PieChartReport: React.FC<PieChartReportProps> = (props) => {
<ResponsiveContainer width="100%" height={220}>
<PieChart>
<Pie
activeIndex={activeIndex}
activeShape={renderActiveShape}
shape={renderShape}
data={pieChartData}
cx="50%"
cy="50%"
innerRadius={40}
outerRadius={60}
dataKey="value"
onMouseEnter={onPieEnter}>
dataKey="value">
{pieChartData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
))}
Expand Down
3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { createRoot } from "react-dom/client";
import App from "./components/App";
import "@radix-ui/themes/styles.css";
import "./index.scss";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import apolloClient from "./lib/apollo";

const container = document.getElementById("root") as HTMLElement;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/__snapshots__/AccountCard.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`<AccountCard> renders without crashing 1`] = `
<div>
<div
class="sc-bRKDuR bJhbeN"
class="sc-aXZVf hgATXI"
>
<span
class="rt-Text rt-r-size-8 rt-r-weight-bold"
Expand Down
Loading