CFE-6 debugging notifications
This commit is contained in:
@@ -2,9 +2,10 @@ import {createContext, useEffect, useMemo, useRef, useState} from "react";
|
||||
import {io} from "socket.io-client";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {toast} from "react-toastify";
|
||||
import {toast, ToastContainer} from "react-toastify";
|
||||
import PowerIcon from "@mui/icons-material/Power";
|
||||
import PowerOffIcon from "@mui/icons-material/PowerOff";
|
||||
import useDirection from "@/lib/app/hooks/useDirection";
|
||||
|
||||
export const SocketContext = createContext()
|
||||
|
||||
@@ -13,6 +14,7 @@ export const SocketProvider = ({children}) => {
|
||||
const [connectionError, setConnectionError] = useState(false)
|
||||
const socketToastId = useRef(null);
|
||||
const t = useTranslations()
|
||||
const {directionApp} = useDirection();
|
||||
const socket = useMemo(() => io(process.env.NEXT_PUBLIC_SERVER_SOCKET_URL, {
|
||||
autoConnect: false,
|
||||
auth: {
|
||||
@@ -57,11 +59,20 @@ export const SocketProvider = ({children}) => {
|
||||
return
|
||||
}
|
||||
socketToastId.current = toast.warn(t('socket_is_not_connect_message'), {
|
||||
containerId: 'socket',
|
||||
draggable: false,
|
||||
autoClose: false, closeButton: false, closeOnClick: false, icon: <PowerOffIcon/>
|
||||
})
|
||||
|
||||
}, [connectionError]);
|
||||
|
||||
return <SocketContext.Provider value={{socket}}>{children}</SocketContext.Provider>
|
||||
return (
|
||||
<SocketContext.Provider value={{socket}}>
|
||||
<ToastContainer
|
||||
enableMultiContainer containerId={'socket'}
|
||||
position={directionApp === "ltr" ? "top-right" : "top-left"}
|
||||
rtl={directionApp === 'rtl'}/>
|
||||
{children}
|
||||
</SocketContext.Provider>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import axios from "axios";
|
||||
import {successRequest} from "@/core/utils/succesHandler";
|
||||
import PendingNotification from "@/core/components/notifications/PendingNotification";
|
||||
import {useTranslations} from "next-intl";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import {errorRequest, errorResponse, errorSetting} from "@/core/utils/errorHandler";
|
||||
import useNetwork from "@/lib/app/hooks/useNetwork";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
|
||||
const defaultOptions = {
|
||||
auth: false, data: {}, requestOptions: {
|
||||
@@ -39,7 +39,7 @@ const useRequest = (initOptions) => {
|
||||
reject()
|
||||
return
|
||||
}
|
||||
if (_options.notification && _options.failed.notification.show && _options.pending) PendingNotification(t)
|
||||
if (_options.notification && _options.failed.notification.show && _options.pending) Notifications("pending", t)
|
||||
axios({
|
||||
url: url, method: method, data: _options.data, ..._options.requestOptions
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user