From ad20755608e6da723134765a178a15a1a67cbb57 Mon Sep 17 00:00:00 2001 From: chip Date: Sun, 23 Aug 2020 19:54:34 +0200 Subject: [PATCH] Feat(Bank): Transaction list --- src/apps/bank/components/BankApp.js | 6 ++++ src/apps/bank/components/transactionList.js | 19 +++++++++++++ src/apps/bank/hooks/useBank.js | 31 +++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/apps/bank/components/transactionList.js create mode 100644 src/apps/bank/hooks/useBank.js diff --git a/src/apps/bank/components/BankApp.js b/src/apps/bank/components/BankApp.js index 594f34b..001b014 100644 --- a/src/apps/bank/components/BankApp.js +++ b/src/apps/bank/components/BankApp.js @@ -5,6 +5,8 @@ import { AppWrapper } from "../../../ui/components"; import { AppContent } from "../../../ui/components/AppContent"; import { useTranslation } from "react-i18next"; import { Button } from "@material-ui/core"; +import { useBank } from '../hooks/useBank'; +import { TransactionList } from './transactionList'; import "./BankApp.css"; const useStyles = makeStyles((theme) => ({ @@ -28,6 +30,7 @@ const useStyles = makeStyles((theme) => ({ })); export const BankApp = () => { + const { transactionList } = useBank(); const { t } = useTranslation(); const classes = useStyles(); return ( @@ -47,6 +50,9 @@ export const BankApp = () => { {t("APPS_BANK_TRANSFER")} + ); diff --git a/src/apps/bank/components/transactionList.js b/src/apps/bank/components/transactionList.js new file mode 100644 index 0000000..3171c8b --- /dev/null +++ b/src/apps/bank/components/transactionList.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { List } from '../../../ui/components/List'; +import { ListItem } from '../../../ui/components/ListItem'; +import ListItemText from "@material-ui/core/ListItemText"; + +export const TransactionList = ({ transactions }) => { + return ( + + {transactions.map((transaction) => ( + + + + ))} + + ) +} \ No newline at end of file diff --git a/src/apps/bank/hooks/useBank.js b/src/apps/bank/hooks/useBank.js new file mode 100644 index 0000000..ef206c4 --- /dev/null +++ b/src/apps/bank/hooks/useBank.js @@ -0,0 +1,31 @@ +import { useRecoilState, atom } from 'recoil'; + +const transactionListState = atom({ + key: 'transactionList', + default: [ + { + id: 0, + amount: 300, + type: 'withdraw', + date: '3' + }, + { + id: 1, + amount: 1000, + type: 'withdraw', + date: '3' + }, + { + id: 2, + amount: 50, + type: 'transfer', + date: '2' + }, + ], +}); + +export const useBank = () => { + const [transactionList, setTransactionList] = useRecoilState + (transactionListState); + return { transactionList, setTransactionList }; +} \ No newline at end of file