Feat(Bank): Transaction list

This commit is contained in:
chip committed 2020-08-23 19:54:34 +02:00
1 parent d36cb53106
commit ad20755608
3 files changed
+56

No files matched your search

+6
View File
@@ -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")}
</Button>
</div>
<TransactionList
transactions={transactionList}
/>
</AppContent>
</AppWrapper>
);
@@ -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 (
<List>
{transactions.map((transaction) => (
<ListItem key={transaction.id} divider>
<ListItemText
primary={transaction.amount}
secondary={transaction.type}
/>
</ListItem>
))}
</List>
)
}
+31
View File
@@ -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 };
}