Merge pull request #177 from project-error/feat/bank-enums

Feat(phone): Update to use all enums.
This commit is contained in:
Christopher Gjelten authored and GitHub committed 2021-03-27 17:20:31 +01:00
commit c5115777c5
17 files changed
+47 -30

No files matched your search

+6 -4
View File
@@ -6,6 +6,8 @@ import { useSetRecoilState } from 'recoil';
import { useBankNotification } from './useBankNotification';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { BankEvents } from '../../../../../typings/bank';
import { PhoneEvents } from '../../../../../typings/phone';
export const useBankService = () => {
const setTransaction = useSetRecoilState(bankState.transactions);
@@ -21,9 +23,9 @@ export const useBankService = () => {
});
};
useNuiEvent('BANK', 'setTransaction', setTransaction);
useNuiEvent('BANK', 'setCredentials', setCredentials);
useNuiEvent('BANK', 'setAlert', handleAddAlert);
useNuiEvent('BANK', 'setNotification', setNotification);
useNuiEvent('BANK', BankEvents.SEND_TRANSFERS, setTransaction);
useNuiEvent('BANK', BankEvents.SEND_CREDENTIALS, setCredentials);
useNuiEvent('BANK', BankEvents.SEND_ALERT, handleAddAlert);
useNuiEvent('BANK', BankEvents.SEND_NOTIFICATION, setNotification);
return { useTransactions, useCredentials, useBankNotification };
};
@@ -4,6 +4,7 @@ import { contactsState } from './state';
import { useContacts } from './useContacts';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { ContactEvents } from '../../../../../typings/contact';
export const useContactsService = () => {
const setContacts = useSetRecoilState(contactsState.contacts);
@@ -17,7 +18,7 @@ export const useContactsService = () => {
});
};
useNuiEvent('CONTACTS', 'setContacts', setContacts);
useNuiEvent('CONTACTS', 'setAlert', handleAddAlert);
useNuiEvent('CONTACTS', ContactEvents.SEND_CONTACTS, setContacts);
useNuiEvent('CONTACTS', ContactEvents.SEND_ALERT, handleAddAlert);
return useContacts();
};
@@ -1,8 +1,9 @@
import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { dialState } from './state';
import { CallEvents } from '../../../../../typings/call';
export const useDialService = () => {
const setHistory = useSetRecoilState(dialState.history);
useNuiEvent('DIALER', 'setHistory', setHistory);
useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory);
};
@@ -3,6 +3,7 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { noteStates } from './state';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { NotesEvents } from '../../../../../typings/notes';
export const useNotesService = () => {
const { addAlert } = useSnackbar();
@@ -16,6 +17,6 @@ export const useNotesService = () => {
});
};
useNuiEvent('NOTES', 'setNotes', setNotes);
useNuiEvent('NOTES', 'setAlert', handleAddAlert);
useNuiEvent('NOTES', NotesEvents.SEND_NOTE, setNotes);
useNuiEvent('NOTES', NotesEvents.SEND_ALERT, handleAddAlert);
};
@@ -4,6 +4,7 @@ import { useListing } from './useListing';
import { useSetRecoilState } from 'recoil';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { MarketplaceEvents } from '../../../../../typings/marketplace';
export const useSelloutService = () => {
const setSellout = useSetRecoilState(selloutState.listing);
@@ -17,7 +18,7 @@ export const useSelloutService = () => {
});
};
useNuiEvent('SELLOUT', 'setAlert', handleAddAlert);
useNuiEvent('SELLOUT', 'setListings', setSellout);
useNuiEvent('SELLOUT', MarketplaceEvents.SEND_ALERT, handleAddAlert);
useNuiEvent('SELLOUT', MarketplaceEvents.SEND_LISTING, setSellout);
return useListing();
};
+3 -3
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
import { useSetRecoilState } from 'recoil';
import { useCall } from './useCall';
import { CallProps } from '../../../../../typings/call';
import { CallEvents, CallProps } from '../../../../../typings/call';
import InjectDebugData from '../../debug/InjectDebugData';
import { useCallModal } from './useCallModal';
import { useHistory, useLocation } from 'react-router-dom';
@@ -61,6 +61,6 @@ export const useCallService = () => {
setCall(_call);
setNotification(_call);
};
useNuiEvent<CallProps>('CALL', 'setCaller', _setCall, call);
useNuiEvent<boolean>('CALL', 'callModal', setModal);
useNuiEvent<CallProps>('CALL', CallEvents.SET_CALLER, _setCall, call);
useNuiEvent<boolean>('CALL', CallEvents.SET_CALL_MODAL, setModal);
};
+5 -4
View File
@@ -1,11 +1,12 @@
import { IAlertProps } from '../../typings/alerts';
import { BankEvents } from '../../typings/bank';
import { PhoneEvents } from '../../typings/phone';
onNet(BankEvents.SEND_TRANSFERS, (transfer: any) => {
SendNuiMessage(
JSON.stringify({
app: 'BANK',
method: 'setTransaction',
method: BankEvents.SEND_TRANSFERS,
data: transfer,
}),
);
@@ -15,7 +16,7 @@ onNet(BankEvents.SEND_CREDENTIALS, (credentials: any) => {
SendNuiMessage(
JSON.stringify({
app: 'BANK',
method: 'setCredentials',
method: BankEvents.SEND_CREDENTIALS,
data: credentials,
}),
);
@@ -35,7 +36,7 @@ onNet(BankEvents.TRANSACTION_ALERT, (result: IAlertProps) => {
SendNuiMessage(
JSON.stringify({
app: 'BANK',
method: 'setAlert',
method: BankEvents.SEND_ALERT,
data: result,
}),
);
@@ -45,7 +46,7 @@ onNet(BankEvents.TRANSACTION_NOTIFICATION, (transfer: any) => {
SendNuiMessage(
JSON.stringify({
app: 'BANK',
method: 'setNotification',
method: BankEvents.SEND_NOTIFICATION,
data: transfer,
}),
);
+6 -6
View File
@@ -16,7 +16,7 @@ onNet(CallEvents.START_CALL, (transmitter: string, receiver: string, isTransmitt
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: 'setCaller',
method: CallEvents.SET_CALLER,
data: {
active: true,
transmitter: transmitter,
@@ -40,7 +40,7 @@ onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmi
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: 'setCaller',
method: CallEvents.SET_CALLER,
data: {
active: true,
transmitter: currentCall.transmitter,
@@ -63,7 +63,7 @@ onNet(CallEvents.WAS_REJECTED, () => {
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: 'setCaller',
method: CallEvents.SET_CALLER,
data: {
transmitter: null,
receiver: null,
@@ -93,7 +93,7 @@ onNet(CallEvents.WAS_ENDED, () => {
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: 'setCaller',
method: CallEvents.SET_CALLER,
data: {
transmitter: null,
receiver: null,
@@ -109,7 +109,7 @@ function openCallModal(show: boolean) {
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: 'callModal',
method: CallEvents.SET_CALL_MODAL,
data: show,
}),
);
@@ -119,7 +119,7 @@ onNet(CallEvents.SEND_HISTORY, (calls: ICall) => {
SendNuiMessage(
JSON.stringify({
app: 'DIALER',
method: 'setHistory',
method: CallEvents.SET_CALL_HISTORY,
data: calls,
}),
);
+2 -2
View File
@@ -2,7 +2,7 @@ import { ContactEvents } from '../../typings/contact';
import { sendContactsEvent } from '../utils/messages';
onNet(ContactEvents.SEND_CONTACTS, (contacts: any) => {
sendContactsEvent('setContacts', contacts);
sendContactsEvent(ContactEvents.SEND_CONTACTS, contacts);
});
RegisterNuiCallbackType(ContactEvents.ADD_CONTACT);
@@ -36,5 +36,5 @@ onNet(ContactEvents.DELETE_CONTACT_SUCCESS, () => {
});
onNet(ContactEvents.ACTION_RESULT, (alert: any) => {
sendContactsEvent('setAlert', alert);
sendContactsEvent(ContactEvents.SEND_ALERT, alert);
});
+2 -2
View File
@@ -2,7 +2,7 @@ import { NotesEvents } from '../../typings/notes';
import { sendNotesEvent } from '../utils/messages';
onNet(NotesEvents.SEND_NOTE, (notes: any) => {
sendNotesEvent('setNotes', notes);
sendNotesEvent(NotesEvents.SEND_NOTE, notes);
});
RegisterNuiCallbackType(NotesEvents.ADD_NOTE);
@@ -35,5 +35,5 @@ onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => {
});
onNet(NotesEvents.ACTION_RESULT, (alert: any) => {
sendNotesEvent('setAlert', alert);
sendNotesEvent(NotesEvents.SEND_ALERT, alert);
});
+2 -2
View File
@@ -3,7 +3,7 @@ import { IAlertProps } from '../../typings/alerts';
import { sendMarketplaceEvent } from '../utils/messages';
onNet(MarketplaceEvents.SEND_LISTING, (listings: MarketplaceListing[]) => {
sendMarketplaceEvent('setListings', listings);
sendMarketplaceEvent(MarketplaceEvents.SEND_LISTING, listings);
});
RegisterNuiCallbackType(MarketplaceEvents.ADD_LISTING);
@@ -33,5 +33,5 @@ onNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, () => {
});
onNet(MarketplaceEvents.ACTION_RESULT, (alert: IAlertProps) => {
sendMarketplaceEvent('setAlert', alert);
sendMarketplaceEvent(MarketplaceEvents.SEND_ALERT, alert);
});
+2
View File
@@ -27,4 +27,6 @@ export enum BankEvents {
TRANSACTION_NOTIFICATION = 'npwd:bankTransactionNotification',
SEND_CREDENTIALS = 'npwd:sendBankCredentials',
GET_CREDENTIALS = 'npwd:getBankCredentials',
SEND_ALERT = 'npwd:sendBankAlert',
SEND_NOTIFICATION = 'npwd:sendBankNotification',
}
+3
View File
@@ -37,4 +37,7 @@ export enum CallEvents {
FETCH_CALLS = 'npwd:fetchCalls',
SEND_HISTORY = 'npwd:sendCallHistory',
SEND_HANGUP_ANIM = 'npwd:sendHangupAnim',
SET_CALLER = 'npwd:setCaller',
SET_CALL_MODAL = 'npwd:callModal',
SET_CALL_HISTORY = 'npwd:setCallHistory',
}
+1
View File
@@ -28,4 +28,5 @@ export enum ContactEvents {
DELETE_CONTACT_SUCCESS = 'npwd:deleteSuccess',
UPDATE_CONTACT_SUCCESS = 'npwd:updateContactSuccess',
ACTION_RESULT = 'npwd:contactActionResult',
SEND_ALERT = 'npwd:contactSetAlert',
}
+1
View File
@@ -20,4 +20,5 @@ export enum MarketplaceEvents {
REPORT_LISTING = 'npwd:reportListing',
REPORT_LISTING_SUCCESS = 'npwd:reportListingSuccess',
REPORT_LISTING_SUCESS = 'npwd:reportListingFailed',
SEND_ALERT = 'nwpd:sendListingAlert',
}
+1
View File
@@ -32,4 +32,5 @@ export enum NotesEvents {
UPDATE_NOTE_SUCCESS = 'npwd:updateNoteSuccess',
UPDATE_NOTE_FAILURE = 'npwd:updateNoteFailure',
ACTION_RESULT = 'npwd:notesActionResult',
SEND_ALERT = 'npwd:notesSetAlert',
}
+2
View File
@@ -8,4 +8,6 @@ export enum PhoneEvents {
OPEN_APP_DAILER = 'npwd:app:DIALER',
OPEN_PHONE = 'npwd:open',
CLOSE_PHONE = 'npwd:close',
SET_ALERT = 'npwd:setAlert',
SET_NOTIFICATION = 'npwd:setNotification',
}