mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(phone|resources/bank): useSnackbar for alert
This commit is contained in:
1 parent
1afca13862
commit
47218e63f5
3 files changed
+25
-9
No files matched your search
@@ -5,18 +5,17 @@ import { useCredentials } from './useCredentials';
|
|||||||
import { useBankAlert } from './useBankAlert';
|
import { useBankAlert } from './useBankAlert';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { useBankNotification } from './useBankNotification';
|
import { useBankNotification } from './useBankNotification';
|
||||||
|
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||||
|
|
||||||
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.transferSuccessful);
|
|
||||||
const setNotification = useSetRecoilState(bankState.notification);
|
const setNotification = useSetRecoilState(bankState.notification);
|
||||||
|
const { addAlert } = useSnackbar()
|
||||||
///
|
|
||||||
|
|
||||||
useNuiEvent('BANK', 'setTransaction', setTransaction);
|
useNuiEvent('BANK', 'setTransaction', setTransaction);
|
||||||
useNuiEvent('BANK', 'setCredentials', setCredentials);
|
useNuiEvent('BANK', 'setCredentials', setCredentials);
|
||||||
useNuiEvent('BANK', 'setAlert', setAlertMessage);
|
useNuiEvent('BANK', 'setAlert', addAlert);
|
||||||
useNuiEvent('BANK', 'setNotification', setNotification);
|
useNuiEvent('BANK', 'setNotification', setNotification);
|
||||||
return { useTransactions, useCredentials, useBankAlert, useBankNotification };
|
return { useTransactions, useCredentials, useBankAlert, useBankNotification };
|
||||||
};
|
};
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { IAlertProps } from '../../phone/src/common/typings/alerts';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
|
|
||||||
onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
|
onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
|
||||||
@@ -30,12 +31,12 @@ onNet(events.BANK_ADD_TRANSFER_SUCCESS, () => {
|
|||||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.BANK_TRANSACTION_ALERT, (bool: boolean) => {
|
onNet(events.BANK_TRANSACTION_ALERT, (result: IAlertProps) => {
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: 'BANK',
|
app: 'BANK',
|
||||||
method: 'setAlert',
|
method: 'setAlert',
|
||||||
data: bool,
|
data: result,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -103,14 +103,30 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
|||||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||||
try {
|
try {
|
||||||
const _identifier = getIdentifier(_source);
|
const _identifier = getIdentifier(_source);
|
||||||
const transferNotify = await addTransfer(_identifier, transfer);
|
await addTransfer(_identifier, transfer);
|
||||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
|
||||||
|
// we need to create a notification for bank. that's why i have commented out.
|
||||||
|
// as well as creating a check if the player has enough money etc....
|
||||||
|
|
||||||
|
//emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
||||||
|
|
||||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, _source);
|
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, _source);
|
||||||
|
emitNet(events.BANK_TRANSACTION_ALERT, _source,
|
||||||
|
{
|
||||||
|
message: 'BANK_ALERT_TRANSFER_SUCCESS',
|
||||||
|
type: 'success'
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bankLogger.error(`Failed to add transaction, ${e.message}`, {
|
bankLogger.error(`Failed to add transaction, ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
});
|
});
|
||||||
emitNet(events.BANK_TRANSACTION_ALERT, _source, false);
|
emitNet(events.BANK_TRANSACTION_ALERT, _source,
|
||||||
|
{
|
||||||
|
message: 'APPS_BANK_ALERT_TRANSFER_FAILURE',
|
||||||
|
type: 'error'
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user