Files
new-phone-who-dis/phone/src/apps/notes/hooks/useNotesService.ts
T
2021-03-25 12:53:18 +01:00

23 lines
764 B
TypeScript

import { useSetRecoilState } from 'recoil';
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();
const setNotes = useSetRecoilState(noteStates.noteItems);
const { t } = useTranslation();
const handleAddAlert = ({ message, type }: IAlert) => {
addAlert({
message: t(`APPS_${message}`),
type,
});
};
useNuiEvent('NOTES', NotesEvents.SEND_NOTE, setNotes);
useNuiEvent('NOTES', NotesEvents.SEND_ALERT, handleAddAlert);
};