mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
feat(notes/nui): useAlet hook
This commit is contained in:
1 parent
fc1f6b3ad3
commit
59973fcf9e
4 files changed
+31
-1
No files matched your search
@@ -13,4 +13,8 @@ export const noteStates = {
|
|||||||
key: 'noteDetail',
|
key: 'noteDetail',
|
||||||
default: null,
|
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 { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||||
import { useNotes } from './useNotes';
|
import { useNotes } from './useNotes';
|
||||||
import { noteStates } from './state';
|
import { noteStates } from './state';
|
||||||
|
import { useNotesAlert } from './useNoteAlert';
|
||||||
|
|
||||||
export const useNotesService = () => {
|
export const useNotesService = () => {
|
||||||
const setNotes = useSetRecoilState(noteStates.noteItems);
|
const setNotes = useSetRecoilState(noteStates.noteItems);
|
||||||
|
const setAlert = useSetRecoilState(noteStates.alert);
|
||||||
useNuiEvent('NOTES', 'setNotes', setNotes);
|
useNuiEvent('NOTES', 'setNotes', setNotes);
|
||||||
return useNotes();
|
useNuiEvent('NOTES', 'setAlert', setAlert)
|
||||||
|
return { useNotes, useNotesAlert };
|
||||||
};
|
};
|
||||||
@@ -1,3 +1,18 @@
|
|||||||
|
export type AlertCategory =
|
||||||
|
| 'NOTES_ADD_SUCCESS'
|
||||||
|
| 'NOTES_ADD_FAILED'
|
||||||
|
| 'NOTES_UPDATE_SUCCESS'
|
||||||
|
| 'NOTES_UPDATE_FAILED'
|
||||||
|
| 'NOTES_DELETE_SUCCESS'
|
||||||
|
| 'NOTES_DELETE_FAILED'
|
||||||
|
|
||||||
|
|
||||||
|
export interface INotesAlert {
|
||||||
|
alert: AlertCategory;
|
||||||
|
setAlert: (type: AlertCategory) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Note {
|
export interface Note {
|
||||||
id?: number;
|
id?: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
Reference in new issue
Block a user