mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(bank/nui): state and hooks for alert and notificatioln
This commit is contained in:
1 parent
3d865dd887
commit
e6cee7b414
4 files changed
+30
-7
No files matched your search
@@ -9,7 +9,7 @@ export const bankState = {
|
||||
key: 'modalVisibility',
|
||||
default: false,
|
||||
}),
|
||||
bankAlert: atom({
|
||||
transferSuccessful: atom({
|
||||
key: 'bankAlert',
|
||||
default: null
|
||||
}),
|
||||
@@ -17,4 +17,8 @@ export const bankState = {
|
||||
key: 'bankCredentails',
|
||||
default: null
|
||||
}),
|
||||
notification: atom({
|
||||
key: 'bankNotification',
|
||||
default: null
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { bankState } from './state';
|
||||
|
||||
export const useBankAlert = () => {
|
||||
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.bankAlert);
|
||||
export const useBankAlert = (): any => {
|
||||
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.transferSuccessful);
|
||||
return { bankAlert, setBankAlert };
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { Transfer } from '../../../common/interfaces/bank';
|
||||
import { bankState } from './state';
|
||||
|
||||
interface IBankNotification {
|
||||
notification: Transfer | null;
|
||||
}
|
||||
|
||||
export const useBankNotification = (): IBankNotification => {
|
||||
const notification = useRecoilValue<Transfer | null>(bankState.notification);
|
||||
return { notification }
|
||||
}
|
||||
@@ -4,13 +4,19 @@ import { useTransactions } from './useTransactions'
|
||||
import { useCredentials } from './useCredentials';
|
||||
import { useBankAlert } from './useBankAlert';
|
||||
import { useSetRecoilState } from 'recoil'
|
||||
import { useBankNotification } from './useBankNotification';
|
||||
|
||||
export const useBankService = () => {
|
||||
const setTransaction = useSetRecoilState(bankState.transactions)
|
||||
const setCredentials = useSetRecoilState(bankState.bankCredentials)
|
||||
const setAlertMessage = useSetRecoilState(bankState.bankAlert)
|
||||
const setAlertMessage = useSetRecoilState(bankState.transferSuccessful)
|
||||
const setNotification = useSetRecoilState(bankState.notification);
|
||||
|
||||
///
|
||||
|
||||
useNuiEvent('BANK', 'setTransaction', setTransaction);
|
||||
useNuiEvent('BANK', 'setCredentials', setCredentials)
|
||||
useNuiEvent('BANK', 'setAlert', setAlertMessage)
|
||||
return {useTransactions, useCredentials, useBankAlert};
|
||||
useNuiEvent('BANK', 'setCredentials', setCredentials);
|
||||
useNuiEvent('BANK', 'setAlert', setAlertMessage);
|
||||
useNuiEvent('BANK', 'setNotification', setNotification);
|
||||
return { useTransactions, useCredentials, useBankAlert, useBankNotification };
|
||||
}
|
||||
Reference in new issue
Block a user