diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts index 643211f..2e5beeb 100644 --- a/phone/src/apps/dialer/hooks/useDialService.ts +++ b/phone/src/apps/dialer/hooks/useDialService.ts @@ -2,8 +2,21 @@ import { useSetRecoilState } from 'recoil'; import { useNuiEvent } from 'fivem-nui-react-lib'; import { dialState } from './state'; import { CallEvents } from '../../../../../typings/call'; +import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; +import { useTranslation } from 'react-i18next'; export const useDialService = () => { + const { addAlert } = useSnackbar(); + const { t } = useTranslation(); + + const handleAddAlert = ({ message, type }: IAlert) => { + addAlert({ + message: t(`APPS_${message}`), + type, + }); + }; + const setHistory = useSetRecoilState(dialState.history); useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory); + useNuiEvent('DAILER', CallEvents.SEND_ALERT, handleAddAlert); }; diff --git a/resources/server/calls/calls.service.ts b/resources/server/calls/calls.service.ts index a826397..fe9c671 100644 --- a/resources/server/calls/calls.service.ts +++ b/resources/server/calls/calls.service.ts @@ -4,6 +4,7 @@ import CallsDB, { CallsRepo } from './calls.db'; import { v4 as uuidv4 } from 'uuid'; import PlayerService from '../players/player.service'; import { callLogger } from './calls.utils'; +import { ContactEvents } from '../../../typings/contact'; class CallsService { private callMap: Collection; @@ -58,6 +59,12 @@ class CallsService { if (!receivingPlayer) { // TODO: handle offline player + + // FIXME: Add actual localization for this. + emitNet(CallEvents.ACTION_RESULT, src, { + message: 'Could not reach player', + type: 'error', + }); return; } diff --git a/typings/call.ts b/typings/call.ts index 0e3dd25..a3edf59 100644 --- a/typings/call.ts +++ b/typings/call.ts @@ -33,4 +33,6 @@ export enum CallEvents { SET_CALLER = 'npwd:setCaller', SET_CALL_MODAL = 'npwd:callModal', SET_CALL_HISTORY = 'npwd:setCallHistory', + ACTION_RESULT = 'npwd:callsActionResult', + SEND_ALERT = 'npwd:callSetAlert', }