mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
25 lines
844 B
TypeScript
25 lines
844 B
TypeScript
import { useNuiEvent } from 'fivem-nui-react-lib';
|
|
import { useSetRecoilState } from 'recoil';
|
|
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);
|
|
const { addAlert } = useSnackbar();
|
|
const { t } = useTranslation();
|
|
|
|
const handleAddAlert = ({ message, type }: IAlert) => {
|
|
addAlert({
|
|
message: t(`APPS_${message}`),
|
|
type,
|
|
});
|
|
};
|
|
|
|
useNuiEvent('CONTACTS', ContactEvents.SEND_CONTACTS, setContacts);
|
|
useNuiEvent('CONTACTS', ContactEvents.SEND_ALERT, handleAddAlert);
|
|
return useContacts();
|
|
};
|