-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cdf84e
commit a49f23c
Showing
16 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<Header title="Carteira" /> | ||
|
||
<main className="min-h-[100dvh] w-full flex flex-col pt-2 container-padding"> | ||
<section> | ||
<h2 className="font-bold text-lg">Resumo</h2> | ||
|
||
<div> | ||
<div className="flex flex-row justify-between"> | ||
<span>Saldo total</span> | ||
<span> | ||
{formatMoney( | ||
bankAccounts.reduce((acc, cur) => acc + cur.balance, 0) + | ||
cards.reduce((acc, cur) => acc + (cur.balance || 0), 0), | ||
)} | ||
</span> | ||
</div> | ||
<div className="pl-3 text-sm"> | ||
<div className="flex flex-row justify-between"> | ||
<span>Bancos</span> | ||
<span> | ||
{formatMoney( | ||
bankAccounts.reduce((acc, cur) => acc + cur.balance, 0), | ||
)} | ||
</span> | ||
</div> | ||
|
||
<div className="flex flex-row justify-between"> | ||
<span>Vale Alimentação</span> | ||
<span> | ||
{formatMoney( | ||
cards.reduce((acc, cur) => { | ||
if (cur.type === CardTypeEnum.VA) { | ||
return acc + (cur.balance || 0); | ||
} | ||
|
||
return acc; | ||
}, 0), | ||
)} | ||
</span> | ||
</div> | ||
|
||
<div className="flex flex-row justify-between"> | ||
<span>Vale Refeição</span> | ||
<span> | ||
{formatMoney( | ||
cards.reduce((acc, cur) => { | ||
if (cur.type === CardTypeEnum.VR) { | ||
return acc + (cur.balance || 0); | ||
} | ||
|
||
return acc; | ||
}, 0), | ||
)} | ||
</span> | ||
</div> | ||
|
||
<div className="flex flex-row justify-between"> | ||
<span>Vale Transporte</span> | ||
<span> | ||
{formatMoney( | ||
cards.reduce((acc, cur) => { | ||
if (cur.type === CardTypeEnum.VT) { | ||
return acc + (cur.balance || 0); | ||
} | ||
|
||
return acc; | ||
}, 0), | ||
)} | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<div className="flex flex-row justify-between"> | ||
<span>Fatura total</span> | ||
<span> | ||
{formatMoney( | ||
cards.reduce((acc, cur) => { | ||
if (cur.type === CardTypeEnum.CREDIT) { | ||
return acc + 0; | ||
} | ||
|
||
return acc; | ||
}, 0), | ||
)} | ||
</span> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<Space /> | ||
|
||
<section> | ||
<h2 className="font-bold text-lg">Contas</h2> | ||
|
||
<div className="flex flex-col gap-1"> | ||
{bankAccounts.map((ba) => ( | ||
<WalletItem | ||
key={ba.bankAccountId} | ||
iconUrl={ba.iconUrl} | ||
label={formatBankAccount(ba.accountNumber)} | ||
name={ba.name} | ||
valueLabel="Saldo" | ||
value={formatMoney(ba.balance)} | ||
/> | ||
))} | ||
|
||
<button className="btn"> | ||
<PiPlusCircleBold /> Adicionar nova conta | ||
</button> | ||
</div> | ||
</section> | ||
|
||
<Space /> | ||
|
||
<section> | ||
<h2 className="font-bold text-lg">Cartões</h2> | ||
|
||
<div className="flex flex-col gap-1"> | ||
{cards.map((c) => ( | ||
<WalletItem | ||
key={c.bankAccountId} | ||
iconUrl={c.iconUrl} | ||
label={`**** ${c.lastFourDigits}`} | ||
name={c.name} | ||
valueLabel={c.type === CardTypeEnum.CREDIT ? "Fatura" : "Saldo"} | ||
value={formatMoney(0)} | ||
/> | ||
))} | ||
|
||
<button className="btn"> | ||
<PiPlusCircleBold /> Adicionar novo cartão | ||
</button> | ||
</div> | ||
</section> | ||
</main> | ||
</> | ||
); | ||
}; | ||
|
||
export default Wallet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MdKeyboardArrowRight } from "react-icons/md"; | ||
|
||
interface Props { | ||
iconUrl: string; | ||
name: string; | ||
label: string; | ||
valueLabel: string; | ||
value: string; | ||
} | ||
|
||
export const WalletItem = ({ | ||
iconUrl, | ||
name, | ||
label, | ||
valueLabel, | ||
value, | ||
}: Props) => { | ||
return ( | ||
<div className="relative grid grid-cols-7 gap-1 items-center bg-accent text-accent-content container-padding rounded"> | ||
<img src={iconUrl} alt={label} className="w-12 h-full rounded" /> | ||
|
||
<div className="flex flex-col col-span-3"> | ||
<span className="font-semibold">{name}</span> | ||
<span className="text-sm">{label}</span> | ||
</div> | ||
|
||
<div className="flex flex-col col-span-3"> | ||
<span className="text-sm">{valueLabel}</span> | ||
<span>{value}</span> | ||
</div> | ||
|
||
<button className="absolute right-2 top-7 text-2xl flex justify-end"> | ||
<MdKeyboardArrowRight /> | ||
</button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ export enum CardTypeEnum { | |
"DEBIT" = "DEBIT", | ||
"VA" = "VA", | ||
"VR" = "VR", | ||
"VT" = "VT", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters