From 7ca802958dcc62d8e9dda1d619c596a788661637 Mon Sep 17 00:00:00 2001 From: Eduardo Parra Date: Tue, 27 Sep 2022 21:19:56 +0200 Subject: [PATCH] Add totals of years (#53) --- package-lock.json | 2 +- .../Year/__snapshots__/Year.test.tsx.snap | 106 ++++++++++++++++++ .../src/pages/Year/components/YearCard.tsx | 28 +++++ .../client/src/pages/Year/components/index.ts | 1 + packages/client/src/pages/Year/index.tsx | 17 ++- 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 packages/client/src/pages/Year/components/YearCard.tsx diff --git a/package-lock.json b/package-lock.json index 489c69b7..e138e5e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15449,7 +15449,7 @@ "@ant-design/icons": "^4.7.0", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", - "@faker-js/faker": "*", + "@faker-js/faker": "^7.5.0", "@mui/material": "^5.9.0", "@mui/x-date-pickers": "^5.0.0-alpha.7", "@soker90/react-mui-table": "^1.0.3", diff --git a/packages/client/src/pages/Year/__snapshots__/Year.test.tsx.snap b/packages/client/src/pages/Year/__snapshots__/Year.test.tsx.snap index d6bed29e..6fc6e13e 100644 --- a/packages/client/src/pages/Year/__snapshots__/Year.test.tsx.snap +++ b/packages/client/src/pages/Year/__snapshots__/Year.test.tsx.snap @@ -88,6 +88,112 @@ exports[`Year > renders without crashing 1`] = ` class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root" /> +
+
+
+
+
+
+ Ingresos +
+
+
+

+ 0 € +

+
+
+
+
+
+
+
+
+
+
+
+ Gastos +
+
+
+

+ 0 € +

+
+
+
+
+
+
+
+
+
+
+
+ Balance +
+
+
+

+ 0 € +

+
+
+
+
+
+
+
diff --git a/packages/client/src/pages/Year/components/YearCard.tsx b/packages/client/src/pages/Year/components/YearCard.tsx new file mode 100644 index 00000000..ee51ce29 --- /dev/null +++ b/packages/client/src/pages/Year/components/YearCard.tsx @@ -0,0 +1,28 @@ +import { Grid, Stack, Typography } from '@mui/material' +import { MainCard } from 'components' +import { format } from 'utils' + +interface Props { + title: string + data?: number + color?: string +} + +const YearCard = ({ title, data = 0, color }: Props) => ( + + + + {title} + + + + + {format.euro(data)} + + + + + +) + +export default YearCard diff --git a/packages/client/src/pages/Year/components/index.ts b/packages/client/src/pages/Year/components/index.ts index eceb0c9c..7a93c103 100644 --- a/packages/client/src/pages/Year/components/index.ts +++ b/packages/client/src/pages/Year/components/index.ts @@ -1,2 +1,3 @@ export { default as Header } from './Header' export { default as YearTable } from './YearTable' +export { default as YearCard } from './YearCard' diff --git a/packages/client/src/pages/Year/index.tsx b/packages/client/src/pages/Year/index.tsx index 2269a411..1465ad47 100644 --- a/packages/client/src/pages/Year/index.tsx +++ b/packages/client/src/pages/Year/index.tsx @@ -2,17 +2,30 @@ import { useParams } from 'react-router-dom' import { useBudgetsYear } from './hooks' -import { Header, YearTable } from './components' -import { Typography } from '@mui/material' +import { Header, YearCard, YearTable } from './components' +import { Grid, Typography } from '@mui/material' import { MainCard } from 'components' const Budgets = () => { const { year } = useParams() const { expenses, incomes } = useBudgetsYear({ year }) + const balance = (incomes?.at?.(-1)?.total ?? 0) - (expenses?.at?.(-1)?.total ?? 0) + return ( <>
+ + + + + + + + + + + GASTOS