mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
Merge pull request #18 from Re-Ignited-Development/feat/bank
Feat/bank - need to fix backend for transactions
This commit is contained in:
27 files changed
+872
-50
No files matched your search
+49
-2
@@ -34,6 +34,23 @@ setTimeout(() => {
|
||||
);
|
||||
}, 1000);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
data: {
|
||||
app: "BANK",
|
||||
method: "setCredentials",
|
||||
data:
|
||||
{
|
||||
name: "Firstname Lastname",
|
||||
balance: 2000
|
||||
}
|
||||
},
|
||||
})
|
||||
);
|
||||
}, 1000);
|
||||
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
@@ -44,13 +61,43 @@ setTimeout(() => {
|
||||
{
|
||||
id: 1,
|
||||
amount: 200,
|
||||
type: 'transfer'
|
||||
type: 'Deposit',
|
||||
source: "chip"
|
||||
},{
|
||||
id: 2,
|
||||
amount: 200,
|
||||
type: 'Withdraw',
|
||||
source: "chip"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
amount: 200,
|
||||
type: 'Withdraw',
|
||||
source: "chip"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
amount: 50,
|
||||
type: 'Deposit',
|
||||
source: "chip"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
amount: 50,
|
||||
type: 'Deposit',
|
||||
source: "chip"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
amount: 50,
|
||||
type: 'Deposit',
|
||||
source: "chip"
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
}, 1000)
|
||||
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
|
||||
@@ -1 +1,45 @@
|
||||
@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap");
|
||||
|
||||
/* #### Generated By: http://www.cufonfonts.com #### */
|
||||
|
||||
@font-face {
|
||||
font-family: 'Bahnschrift Regular';
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: local('Bahnschrift Regular'), url('../fonts/BAHNSCHRIFT.woff') format('woff');
|
||||
}
|
||||
|
||||
#account-section, #transaction-section {
|
||||
font-family: 'Bahnschrift Regular'
|
||||
}
|
||||
|
||||
#transaction-section .MuiTablePagination-root {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#transaction-section .MuiTablePagination-caption {
|
||||
font-size: 15px;
|
||||
font-family: 'Bahnschrift Regular';
|
||||
}
|
||||
|
||||
#transaction-section .MuiTablePagination-actions {
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
|
||||
#bank-app .Mui-selected {
|
||||
color: #388CF8 !important;
|
||||
}
|
||||
|
||||
#bank-title {
|
||||
font-family: 'Bebas Neue', cursive;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
.card-name {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#actionButton a {
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1,19 +1,26 @@
|
||||
import React from "react";
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
import { BankTitle } from './BankTitle';
|
||||
import { makeStyles, Paper, Typography } from "@material-ui/core";
|
||||
import { BankTitle } from "./BankTitle";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { Button } from "../../../ui/components/Button";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTransactions } from "../hooks/useTransactions";
|
||||
import { TransactionList } from './transactions/TransactionList';
|
||||
import "./BankApp.css";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { TransferModal } from './transfers/TransferModal';
|
||||
import { TransferModal } from "./transfers/TransferModal";
|
||||
|
||||
import { useBankModal } from '../hooks/useBankModal';
|
||||
import { useModal } from "../../twitter/hooks/useModal";
|
||||
import { useBankModal } from "../hooks/useBankModal";
|
||||
import { useCredentials } from "../hooks/useCredentials";
|
||||
|
||||
import { Switch, Route } from "react-router-dom";
|
||||
|
||||
// image
|
||||
import CreditCard from '../img/credit-card.png'
|
||||
import { NavigationBar } from "./navigation/NavigationBar";
|
||||
|
||||
import { BankHome } from './home/BankHome';
|
||||
import { BankAccount } from './account/BankAccount';
|
||||
import { TransactionList } from "./transactions/TransactionList";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -41,29 +48,27 @@ const useStyles = makeStyles((theme) => ({
|
||||
}));
|
||||
|
||||
export const BankApp = () => {
|
||||
|
||||
const { showBankModal, setShowBankModal } = useBankModal()
|
||||
|
||||
const { transactionList } = useTransactions();
|
||||
const { showBankModal, setShowBankModal } = useBankModal();
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles();
|
||||
|
||||
|
||||
const openTransactionsModal = () => {
|
||||
setShowBankModal(true)
|
||||
}
|
||||
setShowBankModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppWrapper id="bank-app">
|
||||
<BankTitle />
|
||||
<TransferModal />
|
||||
<div className={showBankModal ? classes.backgroundModal : undefined} />
|
||||
<AppContent>
|
||||
<div>
|
||||
<Button onClick={openTransactionsModal} fullWidth>{t("APPS_BANK_TRANSFER")}</Button>
|
||||
</div>
|
||||
<TransactionList transactions={transactionList}/>
|
||||
<Switch>
|
||||
<Route path="/bank" exact component={BankHome} />
|
||||
<Route path="/bank/account" exact component={BankAccount} />
|
||||
<Route path="/bank/transactions" exact component={TransactionList} />
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<NavigationBar />
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -3,11 +3,13 @@ import Paper from "@material-ui/core/Paper";
|
||||
import { Typography ,makeStyles } from "@material-ui/core";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
import './BankApp.css'
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
height: "90px",
|
||||
width: "100%",
|
||||
display: "block",
|
||||
display: "flex",
|
||||
margin: 0,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
@@ -24,10 +26,7 @@ export const BankTitle = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.root} square variant="outlined" elevation={24}>
|
||||
<Typography style={{ margin: 0}} variant="h4">WhoDis Banking</Typography>
|
||||
|
||||
|
||||
<Typography variant="subtitle2">Some player name</Typography>
|
||||
<Typography id="bank-title" style={{ margin: 0}} variant="h4">WhoDis Banking</Typography>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { makeStyles, Paper, Typography, Button } from "@material-ui/core";
|
||||
import { useTransactions } from "../../hooks/useTransactions";
|
||||
import { red } from "@material-ui/core/colors";
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
width: "100%",
|
||||
},
|
||||
header: {
|
||||
width: "90%",
|
||||
display: "flex",
|
||||
justifyItems: "center",
|
||||
justifyContent: "space-between",
|
||||
margin: "auto",
|
||||
},
|
||||
title: {
|
||||
padding: 7,
|
||||
borderRadius: "10px",
|
||||
display: "flex",
|
||||
justifyItems: "center",
|
||||
justifyContent: "center",
|
||||
fontSize: "24px",
|
||||
},
|
||||
seeAll: {
|
||||
fontFamily: "Bahnschrift Regular",
|
||||
fontWeight: "bold",
|
||||
height: 'auto'
|
||||
},
|
||||
transcationDiv: {
|
||||
marginTop: '-30px',
|
||||
},
|
||||
transactions: {
|
||||
marginLeft: "32px",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
borderBottom: "2px solid #707070",
|
||||
width: "85%",
|
||||
margin: "auto",
|
||||
},
|
||||
tranSource: {
|
||||
fontSize: "22px",
|
||||
},
|
||||
tranType: {
|
||||
fontSize: "18px",
|
||||
fontWeight: "bold",
|
||||
color: "#BFBFBF",
|
||||
marginTop: "-18px",
|
||||
width: "100%",
|
||||
},
|
||||
|
||||
depositType: {
|
||||
color: "#55B452",
|
||||
marginRight: "32px",
|
||||
fontSize: "22px",
|
||||
fontWeight: "bold",
|
||||
},
|
||||
withdrawType: {
|
||||
color: "#FF5E5E",
|
||||
marginRight: "32px",
|
||||
fontSize: "22px",
|
||||
fontWeight: "bold",
|
||||
},
|
||||
}));
|
||||
|
||||
export const AccountTransactions = (): any => {
|
||||
const classes = useStyles();
|
||||
|
||||
const TransactionTypes = {
|
||||
Deposit: classes.depositType,
|
||||
Withdraw: classes.withdrawType,
|
||||
Transfer: classes.depositType
|
||||
};
|
||||
|
||||
const { transactionList } = useTransactions();
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div id="account-section">
|
||||
<div className={classes.header}>
|
||||
<h2 className={classes.title}>{t("APPS_BANK_ACCOUNT_TRANSACTIONS")}</h2>
|
||||
<Button className={classes.seeAll}>
|
||||
{t("APPS_BANK_ACCOUNT_SEE_TRANSACTION")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className={classes.transcationDiv}>
|
||||
{transactionList.slice(0, 3).map((transaction: any) => (
|
||||
<div className={classes.transactions}>
|
||||
<div>
|
||||
<h1 className={classes.tranSource}>{transaction.source}</h1>
|
||||
<p className={classes.tranType}>{transaction.type}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className={TransactionTypes[transaction.type]}>
|
||||
{transaction.type == "Withdraw" ? "-" : "+"}
|
||||
{transaction.amount}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import React from 'react'
|
||||
import { Button } from "../../../../ui/components/Button";
|
||||
import { makeStyles, Paper, Typography } from "@material-ui/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { BankCard } from './BankCard';
|
||||
import { AccountTransactions } from './AccountTransactions';
|
||||
import { useCredentials } from '../../hooks/useCredentials';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
width: '100%',
|
||||
fontFamily: 'Bahnschrift Regular'
|
||||
},
|
||||
title: {
|
||||
fontSize: '30px',
|
||||
marginLeft: '29px'
|
||||
}
|
||||
}))
|
||||
|
||||
export const BankAccount = () => {
|
||||
const classes = useStyles();
|
||||
const { credentials } = useCredentials();
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<div>
|
||||
<h1 className={classes.title} >{t("APPS_BANK_ACCOUNT_TITLE")}</h1>
|
||||
</div>
|
||||
<BankCard name={credentials.name} account="Checking" balance={credentials.balance} />
|
||||
<AccountTransactions />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import React from 'react'
|
||||
import { makeStyles, Box, Typography } from "@material-ui/core";
|
||||
import { shadows } from '@material-ui/system';
|
||||
|
||||
/*
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-wrap: break-word;
|
||||
display: block;
|
||||
line-height: 1em;
|
||||
max-height: 2em; */
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
background: '#388CF8',
|
||||
height: '179px',
|
||||
width: '350px',
|
||||
margin: 'auto',
|
||||
borderRadius: '15px',
|
||||
fontFamily: 'Bahnschrift Regular'
|
||||
},
|
||||
cardName: {
|
||||
margin: 10,
|
||||
paddingTop: 15,
|
||||
fontSize: '24px',
|
||||
},
|
||||
cardAccount: {
|
||||
margin: '10px',
|
||||
marginTop: '10px',
|
||||
color: '#DFDFDF',
|
||||
fontWeight: 'bold',
|
||||
borderBottom: '2px solid #D8D1D1',
|
||||
paddingBottom: 5
|
||||
},
|
||||
balance: {
|
||||
position: "absolute",
|
||||
bottom: '53%',
|
||||
left: '10%'
|
||||
},
|
||||
balanceFont: {
|
||||
fontSize: '29px'
|
||||
}
|
||||
}))
|
||||
|
||||
export const BankCard = (props) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Box boxShadow={5} className={classes.root}>
|
||||
<div>
|
||||
<h2 className={classes.cardName}>{props.name}</h2>
|
||||
<p className={classes.cardAccount}>{props.account}</p>
|
||||
</div>
|
||||
<div className={classes.balance}>
|
||||
<h3 className={classes.balanceFont}><span style={{ fontSize: '30px'}}>$</span>{props.balance}</h3>
|
||||
</div>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
|
||||
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",
|
||||
},
|
||||
root: {
|
||||
width: "100%",
|
||||
},
|
||||
header: {
|
||||
width: "90%",
|
||||
display: "flex",
|
||||
justifyItems: "center",
|
||||
justifyContent: "space-between",
|
||||
margin: "auto",
|
||||
},
|
||||
title: {
|
||||
padding: 7,
|
||||
borderRadius: "10px",
|
||||
display: "flex",
|
||||
justifyItems: "center",
|
||||
justifyContent: "center",
|
||||
fontSize: "30px",
|
||||
},
|
||||
seeAll: {
|
||||
fontFamily: "Bahnschrift Regular",
|
||||
fontWeight: "bold",
|
||||
height: "auto",
|
||||
},
|
||||
transcationDiv: {
|
||||
marginTop: "-30px",
|
||||
minHeight: 200,
|
||||
maxHeight: 240
|
||||
},
|
||||
transactions: {
|
||||
marginLeft: "32px",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
borderBottom: "2px solid #707070",
|
||||
width: "85%",
|
||||
margin: "auto",
|
||||
},
|
||||
tranSource: {
|
||||
fontSize: "22px",
|
||||
},
|
||||
tranType: {
|
||||
fontSize: "18px",
|
||||
fontWeight: "bold",
|
||||
color: "#BFBFBF",
|
||||
marginTop: "-18px",
|
||||
width: "100%",
|
||||
},
|
||||
|
||||
depositType: {
|
||||
color: "#55B452",
|
||||
marginRight: "32px",
|
||||
fontSize: "22px",
|
||||
fontWeight: "bold",
|
||||
},
|
||||
withdrawType: {
|
||||
color: "#FF5E5E",
|
||||
marginRight: "32px",
|
||||
fontSize: "22px",
|
||||
fontWeight: "bold",
|
||||
},
|
||||
pagination: {
|
||||
background: '#262525',
|
||||
width: '100%',
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
maxWidth: '100%',
|
||||
overflow: 'hidden',
|
||||
borderBottom: "2px solid #707070"
|
||||
}
|
||||
}))
|
||||
|
||||
export default useStyles
|
||||
@@ -0,0 +1,42 @@
|
||||
import React from "react";
|
||||
import { makeStyles, Paper, Typography } from "@material-ui/core";
|
||||
import { BankTitle } from "../BankTitle";
|
||||
import { Button } from "../../../../ui/components/Button";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTransactions } from "../../hooks/useTransactions";
|
||||
import { TransactionList } from "../transactions/TransactionList";
|
||||
import { TransferModal } from "../transfers/TransferModal";
|
||||
|
||||
import { useBankModal } from "../../hooks/useBankModal";
|
||||
import { useCredentials } from "../../hooks/useCredentials";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
// image
|
||||
import CreditCard from '../img/credit-card.png'
|
||||
import useStyles from './home.styles';
|
||||
|
||||
export const BankHome = () => {
|
||||
const { showBankModal, setShowBankModal } = useBankModal();
|
||||
const { credentials } = useCredentials();
|
||||
const { transactionList } = useTransactions();
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles();
|
||||
|
||||
const openTransactionsModal = () => {
|
||||
setShowBankModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classes.root} >
|
||||
<Typography className={classes.headTitle}><span style={{ fontWeight: 'bold' }}>{t("APPS_BANK_HOME_TITLE")}</span>, {credentials.name}</Typography>
|
||||
<div className={classes.accounts}>
|
||||
<h2 className={classes.accountsType}>Checking:</h2>
|
||||
<p className={classes.accountBalance}>${credentials.balance}</p>
|
||||
</div>
|
||||
<div className={classes.actions}>
|
||||
<Button id="actionButton" className={classes.actionButton}><NavLink to="/bank/account">{t("APPS_BANK_ACCOUNT_LINK")}</NavLink></Button>
|
||||
<Button onClick={openTransactionsModal} className={classes.actionButton}>{t("APPS_BANK_ACTIONS_TRANSFER")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
width: "100%",
|
||||
fontFamily: 'Bahnschrift Regular'
|
||||
},
|
||||
headTitle: {
|
||||
textAlign: 'center',
|
||||
fontSize: '28px',
|
||||
marginTop: 30,
|
||||
},
|
||||
actions: {
|
||||
width: '50%',
|
||||
display: 'block',
|
||||
margin: '0 auto',
|
||||
textAlign: 'center'
|
||||
},
|
||||
actionButton: {
|
||||
background: '#388CF8',
|
||||
width: 200,
|
||||
height: 50,
|
||||
borderRadius: '10px',
|
||||
textDecoration: 'none',
|
||||
margin: 'auto',
|
||||
fontFamily: 'Bahnschrift Regular',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '20px',
|
||||
marginBottom: 20,
|
||||
boxShadow: '0px 2px 7px -2px rgba(0,0,0,0.75)'
|
||||
},
|
||||
accounts: {
|
||||
marginTop: 20,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
margin: 30,
|
||||
borderBottom: '1px solid #707070'
|
||||
},
|
||||
accountsType: {
|
||||
|
||||
},
|
||||
accountBalance: {
|
||||
|
||||
},
|
||||
}))
|
||||
|
||||
export default useStyles;
|
||||
@@ -0,0 +1,51 @@
|
||||
import React, { useState } from 'react'
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faHome, faList, faMoneyCheck } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
width: "100%",
|
||||
},
|
||||
icon: {
|
||||
color: "#f44336",
|
||||
},
|
||||
}))
|
||||
|
||||
export const NavigationBar = () => {
|
||||
const classes = useStyles();
|
||||
const [activePage, setActivePage] = useState(0)
|
||||
return (
|
||||
<BottomNavigation
|
||||
style={{
|
||||
background: '#262525'
|
||||
}}
|
||||
value={activePage}
|
||||
onChange={(event, newPage) => {
|
||||
setActivePage(newPage);
|
||||
}}
|
||||
showLabels
|
||||
className={classes.root}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faHome} />}
|
||||
to="/bank"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faMoneyCheck} />}
|
||||
to="/bank/account"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faList} />}
|
||||
to="/bank/transactions"
|
||||
/>
|
||||
</BottomNavigation>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
import Notification from '../../../../ui/components/Notification';
|
||||
import { useBankAlert } from './../../hooks/useBankAlert';
|
||||
|
||||
export const BankNotification = ({ alert }) => {
|
||||
const { setBankAlert } = useBankAlert();
|
||||
|
||||
const handleClose = () => {
|
||||
setBankAlert(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div></div>
|
||||
)
|
||||
}
|
||||
@@ -1,19 +1,86 @@
|
||||
import React from "react";
|
||||
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, Button } from "@material-ui/core";
|
||||
|
||||
import useStyles from '../bank.styles';
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import TablePagination from '@material-ui/core/TablePagination';
|
||||
|
||||
import { useTransactions } from "../../hooks/useTransactions";
|
||||
|
||||
const columns = [
|
||||
{ id: "type", label: "Type", minWidth: 100 },
|
||||
{ id: "amount", label: "Amount", minWidth: 100 },
|
||||
{
|
||||
id: "message",
|
||||
label: "Message",
|
||||
minWidth: 170,
|
||||
align: "left",
|
||||
format: (value: number) => value.toLocaleString("en-US"),
|
||||
},
|
||||
];
|
||||
|
||||
export const TransactionList = () => {
|
||||
const { transactionList } = useTransactions();
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles();
|
||||
const [page, setPage] = useState(0);
|
||||
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||
|
||||
const TransactionTypes = {
|
||||
Deposit: classes.depositType,
|
||||
Withdraw: classes.withdrawType,
|
||||
Transfer: classes.depositType
|
||||
};
|
||||
|
||||
|
||||
const handleChangePage = (event, newPage) => {
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
const handleChangeRowsPerPage = (event) => {
|
||||
setRowsPerPage(+event.target.value);
|
||||
setPage(0);
|
||||
};
|
||||
|
||||
export const TransactionList = ({ transactions }) => {
|
||||
return (
|
||||
<List>
|
||||
{transactions.map((transaction) => (
|
||||
<ListItem key={transaction.id} divider>
|
||||
<ListItemText
|
||||
primary={transaction.amount}
|
||||
secondary={transaction.type}
|
||||
<div id="transaction-section">
|
||||
<div className={classes.header}>
|
||||
<h2 className={classes.title}>{t("APPS_BANK_ACCOUNT_TRANSACTIONS")}</h2>
|
||||
</div>
|
||||
|
||||
<div className={classes.transcationDiv}>
|
||||
{transactionList
|
||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||
.map((transaction: any) => (
|
||||
<div className={classes.transactions}>
|
||||
<div>
|
||||
<h1 className={classes.tranSource}>{transaction.source}</h1>
|
||||
<p className={classes.tranType}>{transaction.type}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className={TransactionTypes[transaction.type]}>
|
||||
{transaction.type == "Withdraw" ? "-" : "+"}
|
||||
{transaction.amount}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<TablePagination
|
||||
rowsPerPageOptions={[3, 5]}
|
||||
className={classes.pagination}
|
||||
component="div"
|
||||
count={transactionList.length}
|
||||
rowsPerPage={rowsPerPage}
|
||||
page={page}
|
||||
onChangePage={handleChangePage}
|
||||
onChangeRowsPerPage={handleChangeRowsPerPage}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,13 +1,44 @@
|
||||
import React, { useState } from 'react'
|
||||
import Modal from '../../../../ui/components/Modal';
|
||||
import { Button, List, ListItem, TextField } from '@material-ui/core';
|
||||
import { Button, List, ListItem, TextField, makeStyles } from '@material-ui/core';
|
||||
import CloseIcon from '@material-ui/icons/Close';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
import { useBankModal} from '../../hooks/useBankModal';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
width: "60%",
|
||||
margin: 'auto',
|
||||
|
||||
},
|
||||
modalInput: {
|
||||
fontSize: 20
|
||||
},
|
||||
modalInputCenter: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
},
|
||||
transferButton: {
|
||||
background: "#2E7D32",
|
||||
width: 120,
|
||||
padding: 5,
|
||||
margin: "auto",
|
||||
fontSize: 16,
|
||||
marginBottom: 30
|
||||
},
|
||||
closeButton: {
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
width: "10%"
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
export const TransferModal = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
const [ targetID, setTargetID ] = useState('');
|
||||
const [ amount, setAmount ] = useState('');
|
||||
const [ message, setMessage ] = useState('');
|
||||
@@ -24,14 +55,21 @@ export const TransferModal = () => {
|
||||
amount,
|
||||
message
|
||||
})
|
||||
setTimeout(() => {
|
||||
setShowBankModal(false)
|
||||
}, 200)
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal visible={showBankModal} handleClose={_handleClose}>
|
||||
<Button onClick={_handleClose}></Button>
|
||||
<List>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}><CloseIcon /></Button>
|
||||
<List style={{ marginTop: 20 }}>
|
||||
<ListItem>
|
||||
<TextField
|
||||
<TextField
|
||||
inputProps={{ className: classes.modalInputCenter }}
|
||||
fullWidth
|
||||
type="number"
|
||||
placeholder="ID"
|
||||
value={targetID}
|
||||
onChange={e => setTargetID(e.target.value)}
|
||||
@@ -39,20 +77,26 @@ export const TransferModal = () => {
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<TextField
|
||||
inputProps={{ className: classes.modalInputCenter }}
|
||||
placeholder="Amount"
|
||||
fullWidth
|
||||
type="number"
|
||||
value={amount}
|
||||
onChange={e => setAmount(e.target.value)}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<TextField
|
||||
<TextField
|
||||
inputProps={{ className: classes.modalInput }}
|
||||
placeholder="Message"
|
||||
fullWidth
|
||||
value={message}
|
||||
multiline
|
||||
onChange={e => setMessage(e.target.value)}
|
||||
/>
|
||||
</ListItem>
|
||||
<Button onClick={addTransfer}>Transfer</Button>
|
||||
</List>
|
||||
<Button className={classes.transferButton} onClick={addTransfer}>Transfer</Button>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
Binary file not shown.
@@ -8,5 +8,13 @@ export const bankState = {
|
||||
bankModal: atom({
|
||||
key: 'modalVisibility',
|
||||
default: false,
|
||||
}),
|
||||
bankAlert: atom({
|
||||
key: 'bankAlert',
|
||||
default: false
|
||||
}),
|
||||
bankCredentials: atom({
|
||||
key: 'bankCredentails',
|
||||
default: null
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { bankState } from './state';
|
||||
|
||||
export const useBankAlert = () => {
|
||||
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.bankAlert);
|
||||
return { bankAlert, setBankAlert };
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
import { bankState } from './state';
|
||||
import { useTransactions } from './useTransactions'
|
||||
import { useCredentials } from './useCredentials';
|
||||
import { useSetRecoilState } from 'recoil'
|
||||
|
||||
export const useBankService = () => {
|
||||
const setTransaction = useSetRecoilState(bankState.transactions)
|
||||
const setCredentials = useSetRecoilState(bankState.bankCredentials)
|
||||
useNuiEvent('BANK', 'setTransaction', setTransaction);
|
||||
return useTransactions;
|
||||
useNuiEvent('BANK', 'setCredentials', setCredentials)
|
||||
return {useTransactions, useCredentials};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { bankState } from './state';
|
||||
|
||||
export const useCredentials = (): any => {
|
||||
const credentials = useRecoilValue(bankState.bankCredentials);
|
||||
return { credentials };
|
||||
}
|
||||
@@ -8,8 +8,6 @@
|
||||
"APPS_SETTINGS": "Settings",
|
||||
"APPS_BANK": "WhoDis Banking",
|
||||
"APPS_EXAMPLE": "Example app",
|
||||
"APPS_BANK_DEPOSIT": "Deposit",
|
||||
"APPS_BANK_WITHDRAW": "Withdraw",
|
||||
"APPS_BANK_TRANSFER": "Transfer",
|
||||
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper",
|
||||
"APPS_SETTINGS_OPTIONS_FRAME": "Frame",
|
||||
@@ -36,6 +34,11 @@
|
||||
"APPS_TWITTER_TIME_JUST_NOW": "Just now",
|
||||
"APPS_TWITTER_TIME_MINUTES": "m",
|
||||
"APPS_TWITTER_TIME_HOURS": "h",
|
||||
"APPS_TWITTER_TIME_DAYS": "d"
|
||||
"APPS_TWITTER_TIME_DAYS": "d",
|
||||
|
||||
"APPS_BANK_HOME_TITLE": "Welcome, ",
|
||||
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
|
||||
"APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions",
|
||||
"APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all"
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
faAd,
|
||||
faPlaneArrival,
|
||||
faPhoneAlt,
|
||||
faLandmark,
|
||||
faWonSign
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
|
||||
|
||||
@@ -86,7 +86,7 @@ const appsState = atom({
|
||||
{
|
||||
id: "BANK",
|
||||
nameLocale: "APPS_BANK",
|
||||
icon: <FontAwesomeIcon icon={faLandmark} size="xs" />,
|
||||
icon: <FontAwesomeIcon icon={faWonSign} size="xs" />,
|
||||
backgroundColor: blue[900],
|
||||
color: common.white,
|
||||
path: "/bank",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import events from '../utils/events';
|
||||
|
||||
|
||||
onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: "BANK",
|
||||
method: "setTransaction",
|
||||
data: transfer
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
onNet(events.BANK_SEND_CREDENTIALS, (credentials: any) => {
|
||||
console.log("Client:", credentials.balance, credentials.name)
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: "BANK",
|
||||
method: "setCredentials",
|
||||
data: credentials
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
RegisterNuiCallbackType(events.BANK_ADD_TRANSFER);
|
||||
on(`__cfx_nui:${events.BANK_ADD_TRANSFER}`, (data: any) => {
|
||||
const transfer = data;
|
||||
emitNet(events.BANK_ADD_TRANSFER, transfer)
|
||||
|
||||
setTimeout(() => {
|
||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||
}, 500)
|
||||
})
|
||||
@@ -237,6 +237,8 @@ async function Phone() {
|
||||
emitNet('phone:getCredentials')
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||
emitNet(events.BANK_GET_CREDENTIALS);
|
||||
console.log("Sellout fetched from client side")// Gets the credentials. Will eventually most likely only get the phone number and name, idk.
|
||||
SetCursorLocation(0.90, 0.922) //Experimental
|
||||
let res = GetActiveScreenResolution()
|
||||
@@ -274,6 +276,8 @@ async function Phone() {
|
||||
emitNet('phone:getCredentials')
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||
emitNet(events.BANK_GET_CREDENTIALS);
|
||||
console.log("Sellout fetched from client side")
|
||||
SetCursorLocation(0.936, 0.922) //Experimental
|
||||
let res = GetActiveScreenResolution()
|
||||
|
||||
@@ -3,6 +3,7 @@ import './cl_main';
|
||||
import './cl_twitter';
|
||||
import './cl_contacts';
|
||||
import './cl_sellout';
|
||||
import './cl_bank';
|
||||
|
||||
export let ESX: ESXClient = null;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import './sv_twitter';
|
||||
import './sv_main';
|
||||
import './sv_contacts';
|
||||
import './sv_sellout';
|
||||
import './sv_bank';
|
||||
|
||||
export let ESX: ESXServer = null;
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import events from '../utils/events';
|
||||
import { ESX, getSource } from './server';
|
||||
import { pool } from './db';
|
||||
import { resourceLimits } from 'worker_threads';
|
||||
|
||||
interface Transfer {
|
||||
targetID: string;
|
||||
amount: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface Credentials {
|
||||
name: string;
|
||||
balance: number;
|
||||
}
|
||||
|
||||
|
||||
async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||
const query = "SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC"
|
||||
const [ results ] = await pool.query(query, [identifier])
|
||||
const transactions = <Transfer[]>results;
|
||||
|
||||
return transactions;
|
||||
}
|
||||
|
||||
function fetchCredentials(): Credentials {
|
||||
const name = ESX.GetPlayerFromId(getSource()).getName();
|
||||
const balance = ESX.GetPlayerFromId(getSource()).getAccount('bank').money
|
||||
|
||||
const result = {
|
||||
name,
|
||||
balance
|
||||
}
|
||||
|
||||
console.log(result.name, result.balance);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
async function addTransfer(identifier: string, transfer: Transfer): Promise<any> {
|
||||
|
||||
const xPlayer = ESX.GetPlayerFromId(getSource())
|
||||
const bankBalance = xPlayer.getAccount('bank').money;
|
||||
console.log(bankBalance)
|
||||
if (transfer.amount > bankBalance) {
|
||||
console.log("poor man")
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource, 'You do not have enough money on your account', 'error')
|
||||
}
|
||||
else if (transfer.amount <= bankBalance) {
|
||||
const query = "INSERT INTO npwd_bank_transfers (identifier, target, amount, message) VALUES (?, ?, ?, ?)"
|
||||
|
||||
await pool.query(query, [
|
||||
identifier,
|
||||
transfer.targetID,
|
||||
transfer.amount,
|
||||
transfer.message
|
||||
])
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource, 'You succesfully transferred money to someone', 'success')
|
||||
}
|
||||
}
|
||||
|
||||
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
try {
|
||||
const _source = (global as any).source;
|
||||
const _identifier = ESX.GetPlayerFromId(getSource()).getIdentifier()
|
||||
const transfer = await fetchAllTransactions(_identifier);
|
||||
|
||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer)
|
||||
console.log("WOORK")
|
||||
|
||||
} catch (error) {
|
||||
console.log('Failed to fetch transactions', error)
|
||||
}
|
||||
})
|
||||
|
||||
onNet(events.BANK_ADD_TRANSFER, (transfer: Transfer) => {
|
||||
try {
|
||||
const _identifier = ESX.GetPlayerFromId(getSource()).getIdentifier()
|
||||
addTransfer(_identifier, transfer)
|
||||
} catch (error) {
|
||||
console.log('Failed to add transfer', error)
|
||||
}
|
||||
})
|
||||
|
||||
onNet(events.BANK_GET_CREDENTIALS, () => {
|
||||
try {
|
||||
const credentials = fetchCredentials()
|
||||
console.log("New log: ", credentials.balance, credentials.name)
|
||||
emitNet(events.BANK_SEND_CREDENTIALS, getSource(), credentials)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
@@ -31,5 +31,13 @@ export default {
|
||||
// Sellout
|
||||
SELLOUT_ADD_LISTING: 'phone:addListing',
|
||||
SELLOUT_FETCH_LISTING: 'phone:fetchAllListings',
|
||||
SELLOUT_SEND_LISTING: 'phone:sendAllListings'
|
||||
SELLOUT_SEND_LISTING: 'phone:sendAllListings',
|
||||
|
||||
// Bank
|
||||
BANK_ADD_TRANSFER: 'phone:addTransfer',
|
||||
BANK_FETCH_TRANSACTIONS: 'phone:fetchAllTransactions',
|
||||
BANK_SEND_TRANSFERS: 'phone:sendTransfers',
|
||||
BANK_TRANSACTION_ALERT: 'phone:transactionAlert',
|
||||
BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials',
|
||||
BANK_GET_CREDENTIALS: 'phone:getBankCredentials'
|
||||
}
|
||||
Reference in new issue
Block a user