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()} /> -
+