From ad3cd5f19aff68769066f668444ab2b4e7bf7626 Mon Sep 17 00:00:00 2001 From: chip Date: Tue, 20 Oct 2020 15:45:35 +0200 Subject: [PATCH] feat(bank): new states and hooks --- phone/src/apps/bank/components/BankTitle.tsx | 33 ++++++++++++++++++++ phone/src/apps/bank/hooks/state.ts | 12 +++++++ phone/src/apps/bank/hooks/useBankModal.ts | 7 +++++ phone/src/apps/bank/hooks/useBankService.ts | 10 ++++++ phone/src/apps/bank/hooks/useTransactions.ts | 7 +++++ 5 files changed, 69 insertions(+) create mode 100644 phone/src/apps/bank/components/BankTitle.tsx create mode 100644 phone/src/apps/bank/hooks/state.ts create mode 100644 phone/src/apps/bank/hooks/useBankModal.ts create mode 100644 phone/src/apps/bank/hooks/useBankService.ts create mode 100644 phone/src/apps/bank/hooks/useTransactions.ts diff --git a/phone/src/apps/bank/components/BankTitle.tsx b/phone/src/apps/bank/components/BankTitle.tsx new file mode 100644 index 0000000..e70dfee --- /dev/null +++ b/phone/src/apps/bank/components/BankTitle.tsx @@ -0,0 +1,33 @@ +import React from "react"; +import Paper from "@material-ui/core/Paper"; +import { Typography ,makeStyles } from "@material-ui/core"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +const useStyles = makeStyles((theme) => ({ + root: { + height: "90px", + width: "100%", + display: "block", + margin: 0, + justifyContent: "center", + alignItems: "center", + background: "#424242", + }, + icon: { + color: "#f44336", + fontSize: 40, + }, +})); + + +export const BankTitle = () => { + const classes = useStyles(); + return ( + + WhoDis Banking + + + Some player name + + ); +}; diff --git a/phone/src/apps/bank/hooks/state.ts b/phone/src/apps/bank/hooks/state.ts new file mode 100644 index 0000000..a1dd1ac --- /dev/null +++ b/phone/src/apps/bank/hooks/state.ts @@ -0,0 +1,12 @@ +import { atom } from 'recoil'; + +export const bankState = { + transactions: atom({ + key: 'transactionList', + default: [] + }), + bankModal: atom({ + key: 'modalVisibility', + default: false, + }) +} \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useBankModal.ts b/phone/src/apps/bank/hooks/useBankModal.ts new file mode 100644 index 0000000..71afcf8 --- /dev/null +++ b/phone/src/apps/bank/hooks/useBankModal.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { bankState } from './state'; + +export const useBankModal = () => { + const [ showBankModal, setShowBankModal ] = useRecoilState(bankState.bankModal); + return { showBankModal, setShowBankModal }; +} diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts new file mode 100644 index 0000000..f200043 --- /dev/null +++ b/phone/src/apps/bank/hooks/useBankService.ts @@ -0,0 +1,10 @@ +import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; +import { bankState } from './state'; +import { useTransactions } from './useTransactions' +import { useSetRecoilState } from 'recoil' + +export const useBankService = () => { + const setTransaction = useSetRecoilState(bankState.transactions) + useNuiEvent('BANK', 'setTransaction', setTransaction); + return useTransactions; +} \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useTransactions.ts b/phone/src/apps/bank/hooks/useTransactions.ts new file mode 100644 index 0000000..26c7870 --- /dev/null +++ b/phone/src/apps/bank/hooks/useTransactions.ts @@ -0,0 +1,7 @@ +import { useRecoilValue } from "recoil"; +import { bankState } from './state'; + +export const useTransactions = () => { + const transactionList = useRecoilValue(bankState.transactions); + return { transactionList }; +};