feat(notes/nui): useAlet hook

This commit is contained in:
Christopher committed 2021-02-08 18:52:04 +01:00
1 parent fc1f6b3ad3
commit 59973fcf9e
4 files changed
+31 -1

No files matched your search

+4
View File
@@ -13,4 +13,8 @@ export const noteStates = {
key: 'noteDetail',
default: null,
}),
alert: atom({
key: 'notesAlert',
default: null
})
};
@@ -0,0 +1,8 @@
import { useRecoilState } from 'recoil';
import { INotesAlert } from '../../../common/typings/notes';
import { noteStates } from './state';
export const useNotesAlert = (): INotesAlert => {
const [alert, setAlert] = useRecoilState(noteStates.alert)
return { alert, setAlert }
}
@@ -2,9 +2,12 @@ import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { useNotes } from './useNotes';
import { noteStates } from './state';
import { useNotesAlert } from './useNoteAlert';
export const useNotesService = () => {
const setNotes = useSetRecoilState(noteStates.noteItems);
const setAlert = useSetRecoilState(noteStates.alert);
useNuiEvent('NOTES', 'setNotes', setNotes);
return useNotes();
useNuiEvent('NOTES', 'setAlert', setAlert)
return { useNotes, useNotesAlert };
};