mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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',
|
key: 'modalVisibility',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
bankAlert: atom({
|
transferSuccessful: atom({
|
||||||
key: 'bankAlert',
|
key: 'bankAlert',
|
||||||
default: null
|
default: null
|
||||||
}),
|
}),
|
||||||
@@ -17,4 +17,8 @@ export const bankState = {
|
|||||||
key: 'bankCredentails',
|
key: 'bankCredentails',
|
||||||
default: null
|
default: null
|
||||||
}),
|
}),
|
||||||
|
notification: atom({
|
||||||
|
key: 'bankNotification',
|
||||||
|
default: null
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import { bankState } from './state';
|
import { bankState } from './state';
|
||||||
|
|
||||||
export const useBankAlert = () => {
|
export const useBankAlert = (): any => {
|
||||||
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.bankAlert);
|
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.transferSuccessful);
|
||||||
return { bankAlert, setBankAlert };
|
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 { useCredentials } from './useCredentials';
|
||||||
import { useBankAlert } from './useBankAlert';
|
import { useBankAlert } from './useBankAlert';
|
||||||
import { useSetRecoilState } from 'recoil'
|
import { useSetRecoilState } from 'recoil'
|
||||||
|
import { useBankNotification } from './useBankNotification';
|
||||||
|
|
||||||
export const useBankService = () => {
|
export const useBankService = () => {
|
||||||
const setTransaction = useSetRecoilState(bankState.transactions)
|
const setTransaction = useSetRecoilState(bankState.transactions)
|
||||||
const setCredentials = useSetRecoilState(bankState.bankCredentials)
|
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', 'setTransaction', setTransaction);
|
||||||
useNuiEvent('BANK', 'setCredentials', setCredentials)
|
useNuiEvent('BANK', 'setCredentials', setCredentials);
|
||||||
useNuiEvent('BANK', 'setAlert', setAlertMessage)
|
useNuiEvent('BANK', 'setAlert', setAlertMessage);
|
||||||
return {useTransactions, useCredentials, useBankAlert};
|
useNuiEvent('BANK', 'setNotification', setNotification);
|
||||||
|
return { useTransactions, useCredentials, useBankAlert, useBankNotification };
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user