useNotification init
This commit is contained in:
26
src/lib/app/hooks/useNotification.jsx
Normal file
26
src/lib/app/hooks/useNotification.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import useSWR from 'swr'
|
||||
import {GET_SIDEBAR_NOTIFICATION} from "@/core/data/apiRoutes";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
|
||||
const useNotification = () => {
|
||||
const requestServer = useRequest({auth: true})
|
||||
|
||||
//swr config
|
||||
const fetcher = (...args) => {
|
||||
return requestServer(args, 'get', {
|
||||
pending: false,
|
||||
success: {notification: {show: false}}
|
||||
}).then((response) => {
|
||||
return response.data.data;
|
||||
}).catch(() => {
|
||||
})
|
||||
};
|
||||
|
||||
const {data} = useSWR(GET_SIDEBAR_NOTIFICATION, fetcher)
|
||||
const notification_count = data
|
||||
//swr config
|
||||
|
||||
// render data
|
||||
return {notification_count}
|
||||
}
|
||||
export default useNotification
|
||||
Reference in New Issue
Block a user