npm-pkg-hook 1.10.7 → 1.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/hooks/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './useStoreTable/index'
|
|
|
14
14
|
export * from './useSubscriptionValidation'
|
|
15
15
|
export * from './convertToMilitaryTime'
|
|
16
16
|
export * from './useRoles'
|
|
17
|
+
export * from './useLocalBackendIp'
|
|
17
18
|
export * from './statusOpenStores'
|
|
18
19
|
export * from './completeSchedules'
|
|
19
20
|
export * from './useLogout/helpers/BroadcastChannel'
|
|
@@ -10,13 +10,15 @@ export const useConnection = ({ setConnectionStatus }) => {
|
|
|
10
10
|
// Attaching event handler for the load event
|
|
11
11
|
// window.addEventListener('load', updateConnectionStatus);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
// Attaching event handler for the online event
|
|
15
|
+
window.addEventListener('online', function () {
|
|
16
|
+
updateConnectionStatus()
|
|
17
|
+
})
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// Attaching event handler for the offline event
|
|
20
|
+
window.addEventListener('offline', function () {
|
|
21
|
+
updateConnectionStatus()
|
|
22
|
+
})
|
|
23
|
+
}
|
|
22
24
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useQuery, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GraphQL query to get the local IP of the backend server.
|
|
5
|
+
*/
|
|
6
|
+
const GET_LOCAL_BACKEND_IP = gql`
|
|
7
|
+
query GetLocalBackendIp {
|
|
8
|
+
getLocalBackendIp
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook to fetch the local IP address of the backend server.
|
|
14
|
+
*
|
|
15
|
+
* @returns {Object} - Contains the IP string, loading state, and error.
|
|
16
|
+
*/
|
|
17
|
+
export const useLocalBackendIp = () => {
|
|
18
|
+
const { data, loading, error } = useQuery(GET_LOCAL_BACKEND_IP)
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
ip: data?.getLocalBackendIp || null,
|
|
22
|
+
loading,
|
|
23
|
+
error
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import type { MouseEvent } from "react";
|
|
3
2
|
|
|
4
|
-
export function useMouse
|
|
5
|
-
options: { resetOnExit
|
|
3
|
+
export function useMouse(
|
|
4
|
+
options: { resetOnExit } = { resetOnExit: false }
|
|
6
5
|
) {
|
|
7
6
|
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
8
7
|
|
|
9
|
-
const ref = useRef
|
|
8
|
+
const ref = useRef();
|
|
10
9
|
|
|
11
|
-
const setMousePosition = (event
|
|
10
|
+
const setMousePosition = (event) => {
|
|
12
11
|
if (ref.current) {
|
|
13
12
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
14
13
|
|
|
@@ -36,14 +35,14 @@ export function useMouse<T extends HTMLElement = any>(
|
|
|
36
35
|
|
|
37
36
|
useEffect(() => {
|
|
38
37
|
const element = ref?.current ? ref.current : document;
|
|
39
|
-
element.addEventListener("mousemove", setMousePosition
|
|
38
|
+
element.addEventListener("mousemove", setMousePosition);
|
|
40
39
|
if (options.resetOnExit)
|
|
41
|
-
element.addEventListener("mouseleave", resetMousePosition
|
|
40
|
+
element.addEventListener("mouseleave", resetMousePosition);
|
|
42
41
|
|
|
43
42
|
return () => {
|
|
44
|
-
element.removeEventListener("mousemove", setMousePosition
|
|
43
|
+
element.removeEventListener("mousemove", setMousePosition);
|
|
45
44
|
if (options.resetOnExit)
|
|
46
|
-
element.removeEventListener("mouseleave", resetMousePosition
|
|
45
|
+
element.removeEventListener("mouseleave", resetMousePosition);
|
|
47
46
|
};
|
|
48
47
|
}, [ref.current]);
|
|
49
48
|
|