diff --git a/phone/src/apps/bank/components/transactions/TransactionList.tsx b/phone/src/apps/bank/components/transactions/TransactionList.tsx index 111d4e3..5096f30 100644 --- a/phone/src/apps/bank/components/transactions/TransactionList.tsx +++ b/phone/src/apps/bank/components/transactions/TransactionList.tsx @@ -2,60 +2,40 @@ import React, { useState } from "react"; import { List } from "../../../../ui/components/List"; import { ListItem } from "../../../../ui/components/ListItem"; import ListItemText from "@material-ui/core/ListItemText"; -import { Typography, makeStyles } from "@material-ui/core"; +import { Typography, makeStyles, Button } from "@material-ui/core"; + +import useStyles from '../bank.styles'; + +import { useTranslation } from "react-i18next"; -import Table from '@material-ui/core/Table'; -import TableBody from '@material-ui/core/TableBody'; -import TableCell from '@material-ui/core/TableCell'; -import TableContainer from '@material-ui/core/TableContainer'; -import TableHead from '@material-ui/core/TableHead'; -import TableRow from '@material-ui/core/TableRow'; import TablePagination from '@material-ui/core/TablePagination'; -import Paper from '@material-ui/core/Paper'; -import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; -const useStyles = makeStyles((theme) => ({ - paper: { - padding: theme.spacing(1), - textAlign: 'center', - width: "50%", - backgroundColor: "#2d3436", - margin: 20, - color: "#fff", - }, - table: { - width: "100%", - color: "#fff" - }, - cell: { - color: "#fff", - }, - container: { - maxHeight: 350, - }, - list: { - marginTop: "8.5em" - } -})) +import { useTransactions } from "../../hooks/useTransactions"; const columns = [ - { id: 'type', label: 'Type', minWidth: 100 }, - { id: 'amount', label: 'Amount', minWidth: 100 }, + { id: "type", label: "Type", minWidth: 100 }, + { id: "amount", label: "Amount", minWidth: 100 }, { - id: 'message', - label: 'Message', + id: "message", + label: "Message", minWidth: 170, - align: 'left', - format: (value: number) => value.toLocaleString('en-US') + align: "left", + format: (value: number) => value.toLocaleString("en-US"), }, ]; - -export const TransactionList = ({ transactions }) => { - +export const TransactionList = () => { + const { transactionList } = useTransactions(); + const { t } = useTranslation(); const classes = useStyles(); const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(4); + const [rowsPerPage, setRowsPerPage] = useState(5); + + const TransactionTypes = { + Deposit: classes.depositType, + Withdraw: classes.withdrawType, + }; + const handleChangePage = (event, newPage) => { setPage(newPage); @@ -65,52 +45,41 @@ export const TransactionList = ({ transactions }) => { setRowsPerPage(+event.target.value); setPage(0); }; - + return ( - <> - - - - - - {columns.map((column) => ( - - {column.label} - - ))} - - - - {transactions.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((row) => { - return ( - - {columns.map((column) => { - const value = row[column.id]; - return ( - - {column.format && typeof value === 'number' ? column.format(value) : value} - - ); - })} - - ); - })} - -
-
- -
- +
+
+

{t("APPS_BANK_ACCOUNT_TRANSACTIONS")}

+
+ +
+ {transactionList + .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) + .map((transaction: any) => ( +
+
+

{transaction.source}

+

{transaction.type}

+
+
+

+ {transaction.type == "Deposit" ? "+" : "-"} + {transaction.amount} +

+
+
+ ))} + +
+
); };