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