From a49f23c633ce41e8807b273c03b8f768e276c7ae Mon Sep 17 00:00:00 2001 From: Henrique Leite Date: Mon, 13 Nov 2023 08:38:41 -0300 Subject: [PATCH] Add Wallet --- .eslintrc.json | 3 +- src/app/(public)/carteira/page.tsx | 160 ++++++++++++++++++ .../TransactionInOut/index.tsx | 2 +- src/assets/data.ts | 15 ++ src/components/AddTransaction/index.tsx | 2 +- src/components/BudgetCard/index.tsx | 2 +- src/components/ExpensesPerCategory/index.tsx | 2 +- src/components/Footer/NavBar/index.tsx | 18 +- src/components/Inputs/Money/index.tsx | 2 +- src/components/StoresCarousel/Chart/index.tsx | 2 +- src/components/TransactionInOut/index.tsx | 2 +- src/components/WalletItem/index.tsx | 37 ++++ src/types/card.ts | 7 +- src/types/enums/card-type.ts | 1 + src/utils/{money.ts => format.ts} | 5 + tailwind.config.ts | 2 +- 16 files changed, 247 insertions(+), 15 deletions(-) create mode 100644 src/app/(public)/carteira/page.tsx create mode 100644 src/components/WalletItem/index.tsx rename src/utils/{money.ts => format.ts} (50%) diff --git a/.eslintrc.json b/.eslintrc.json index f8364d1..dc8fa20 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,6 +29,7 @@ "groups": ["module", ["parent", "sibling", "index"]], "alphabetize": { "order": "asc", "ignoreCase": true } } - ] + ], + "@next/next/no-img-element": "off" } } diff --git a/src/app/(public)/carteira/page.tsx b/src/app/(public)/carteira/page.tsx new file mode 100644 index 0000000..98dc422 --- /dev/null +++ b/src/app/(public)/carteira/page.tsx @@ -0,0 +1,160 @@ +"use client"; + +import { + bankAccounts as bankAccountsData, + cards as cardsData, +} from "assets/data"; +import { Header } from "components/Header"; +import { Space } from "components/Space"; +import { WalletItem } from "components/WalletItem"; +import { PiPlusCircleBold } from "react-icons/pi"; +import { CardTypeEnum } from "types/enums/card-type"; +import { formatBankAccount } from "utils/format"; +import { formatMoney } from "utils/format"; + +const bankAccounts = Object.values(bankAccountsData); +const cards = Object.values(cardsData); + +const Wallet = () => { + return ( + <> +
+ +
+
+

Resumo

+ +
+
+ Saldo total + + {formatMoney( + bankAccounts.reduce((acc, cur) => acc + cur.balance, 0) + + cards.reduce((acc, cur) => acc + (cur.balance || 0), 0), + )} + +
+
+
+ Bancos + + {formatMoney( + bankAccounts.reduce((acc, cur) => acc + cur.balance, 0), + )} + +
+ +
+ Vale Alimentação + + {formatMoney( + cards.reduce((acc, cur) => { + if (cur.type === CardTypeEnum.VA) { + return acc + (cur.balance || 0); + } + + return acc; + }, 0), + )} + +
+ +
+ Vale Refeição + + {formatMoney( + cards.reduce((acc, cur) => { + if (cur.type === CardTypeEnum.VR) { + return acc + (cur.balance || 0); + } + + return acc; + }, 0), + )} + +
+ +
+ Vale Transporte + + {formatMoney( + cards.reduce((acc, cur) => { + if (cur.type === CardTypeEnum.VT) { + return acc + (cur.balance || 0); + } + + return acc; + }, 0), + )} + +
+
+ +
+ Fatura total + + {formatMoney( + cards.reduce((acc, cur) => { + if (cur.type === CardTypeEnum.CREDIT) { + return acc + 0; + } + + return acc; + }, 0), + )} + +
+
+
+ + + +
+

Contas

+ +
+ {bankAccounts.map((ba) => ( + + ))} + + +
+
+ + + +
+

Cartões

+ +
+ {cards.map((c) => ( + + ))} + + +
+
+
+ + ); +}; + +export default Wallet; diff --git a/src/app/(public)/transacao/[transactionId]/TransactionInOut/index.tsx b/src/app/(public)/transacao/[transactionId]/TransactionInOut/index.tsx index 901b7aa..ee63099 100644 --- a/src/app/(public)/transacao/[transactionId]/TransactionInOut/index.tsx +++ b/src/app/(public)/transacao/[transactionId]/TransactionInOut/index.tsx @@ -6,7 +6,7 @@ import { useCurrentBudget } from "contexts/current-budget"; import { CardTypeEnum } from "types/enums/card-type"; import { TransactionInOut as TransactionInOutType } from "types/transaction"; import { formatFullDate } from "utils/date"; -import { formatMoney } from "utils/money"; +import { formatMoney } from "utils/format"; interface Props { transaction: TransactionInOutType; diff --git a/src/assets/data.ts b/src/assets/data.ts index 4278c1e..fdf33c9 100644 --- a/src/assets/data.ts +++ b/src/assets/data.ts @@ -241,4 +241,19 @@ export const cards: Record = { payAt: PayAtEnum.DUE, payWithBankAccountId: bankAccounts["nubank"].bankAccountId, }, + aleloVa: { + cardId: "aleloVa", + accountId: "foo1", + cardProviderId: "aleloVa", + iconUrl: + "https://logodownload.org/wp-content/uploads/2017/09/alelo-logo-1-599x393.png", + color: "#017958", + type: CardTypeEnum.VA, + network: NetworkEnum.ELO, + name: "Alelo VA", + lastFourDigits: "1234", + + // VA, VR, VT + balance: 1000, + }, }; diff --git a/src/components/AddTransaction/index.tsx b/src/components/AddTransaction/index.tsx index 227ccc9..e3514e2 100644 --- a/src/components/AddTransaction/index.tsx +++ b/src/components/AddTransaction/index.tsx @@ -43,7 +43,7 @@ export const AddTransaction = () => { className="absolute top-0 w-full bg-shadow min-h-[100dvh]" onClick={() => close()} /> -
+