npm-pkg-hook 1.10.9 → 1.11.1

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/.babelrc CHANGED
@@ -1,14 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-react",
12
- "@babel/preset-typescript"
13
- ]
14
- }
package/package.json CHANGED
@@ -6,7 +6,6 @@
6
6
  "file-saver": "2.0.5",
7
7
  "js-cookie": "3.0.1",
8
8
  "lodash": "^4.17.21",
9
- "md5": "2.3.0",
10
9
  "moment": "^2.29.4",
11
10
  "react": "18.1.0",
12
11
  "react-dom": "18.1.0",
@@ -47,5 +46,5 @@
47
46
  "rm": "rm -rf node_modules package-lock.json && npm i",
48
47
  "test": "echo \"Error: no test specified\" && exit 1"
49
48
  },
50
- "version": "1.10.9"
49
+ "version": "1.11.1"
51
50
  }
@@ -134,3 +134,5 @@ export * from './useWeeklyStockMovement'
134
134
  export * from './useSetImageProducts'
135
135
  export * from './useGetSalesAmountToday'
136
136
  export * from './useUpsertGoal'
137
+ export * from './useDashboardComponents'
138
+ export * from './useUpdateModuleOrder'
@@ -0,0 +1,50 @@
1
+ import { useQuery, gql } from '@apollo/client'
2
+
3
+ /**
4
+ * GraphQL query to fetch dashboard components
5
+ */
6
+ const GET_DASHBOARD_COMPONENTS = gql`
7
+ query dashboardComponents {
8
+ dashboardComponents {
9
+ id
10
+ idStore
11
+ idUser
12
+ coordinates
13
+ }
14
+ }
15
+ `
16
+
17
+ /**
18
+ * Custom hook to fetch dashboard components
19
+ * @returns {{
20
+ * data: Array,
21
+ * loading: boolean,
22
+ * error: any,
23
+ * refetch: () => void
24
+ * }}
25
+ */
26
+
27
+ export const useDashboardComponents = ({ callback = () => {} }) => {
28
+ const {
29
+ data,
30
+ loading,
31
+ error,
32
+ refetch
33
+ } = useQuery(GET_DASHBOARD_COMPONENTS, {
34
+ fetchPolicy: 'cache-and-network',
35
+ onCompleted: (data) => {
36
+ if (Array.isArray(data?.dashboardComponents)) {
37
+ try {
38
+ callback(data.dashboardComponents ?? [])
39
+ } catch (err) {
40
+ console.error('Error executing callback:', err)
41
+ }
42
+ }
43
+ },
44
+ onError: (err) => {
45
+ console.error('Error fetching dashboard components:', err)
46
+ }
47
+ })
48
+
49
+ return { data: data?.dashboardComponents ?? [], loading, error, refetch }
50
+ }
@@ -1,4 +1,4 @@
1
- import md5 from 'md5'
1
+ // import md5 from 'md5'
2
2
 
3
3
  async function getCPUInfo () {
4
4
  if (navigator.hardwareConcurrency) {
@@ -68,9 +68,9 @@ async function generateFingerprint () {
68
68
  }
69
69
 
70
70
  const fingerprint = JSON.stringify(fingerprintData)
71
- const uniqueID = md5(fingerprint)
71
+ // const uniqueID = md5(fingerprint)
72
72
 
73
- return uniqueID
73
+ return null
74
74
  }
75
75
 
76
76
  // Función para generar huella digital del audio
@@ -167,6 +167,6 @@ function getTouchscreenInfo () {
167
167
 
168
168
  export async function fingerprintJs () {
169
169
  const fingerprint = await generateFingerprint()
170
- const uniqueID = md5(fingerprint)
171
- return uniqueID
170
+ // const uniqueID = md5(fingerprint)
171
+ return null
172
172
  }
@@ -21,7 +21,10 @@ const GET_MODULES = gql`
21
21
  }
22
22
  `
23
23
 
24
- export const useModules = (dataUser = {}) => {
24
+ export const useModules = ({
25
+ dataUser = {},
26
+ callback = () => {}
27
+ }) => {
25
28
  const { role } = dataUser ?? {
26
29
  role: {
27
30
  permissions: {}
@@ -31,7 +34,17 @@ export const useModules = (dataUser = {}) => {
31
34
  loading,
32
35
  error,
33
36
  data
34
- } = useQuery(GET_MODULES)
37
+ } = useQuery(GET_MODULES, {
38
+ fetchPolicy: 'cache-and-network',
39
+ onCompleted: (data) => {
40
+ if (Array.isArray(data?.modules)) {
41
+ callback(data.modules)
42
+ }
43
+ },
44
+ onError: (error) => {
45
+ console.error('Error fetching modules:', error)
46
+ }
47
+ })
35
48
 
36
49
  const permissions = role?.permissions ?? {}
37
50
 
@@ -0,0 +1,37 @@
1
+ import { useCallback } from 'react'
2
+ import { gql, useMutation } from '@apollo/client'
3
+
4
+ const UPDATE_MODULE_ORDER = gql`
5
+ mutation UpdateModuleOrder($input: [UpdateModuleOrderInput]!) {
6
+ updateModuleOrder(input: $input) {
7
+ success
8
+ message
9
+ modules {
10
+ mId
11
+ mPriority
12
+ }
13
+ errors {
14
+ path
15
+ message
16
+ }
17
+ }
18
+ }
19
+ `
20
+
21
+ export const useUpdateModuleOrder = () => {
22
+ const [updateModuleOrderMutation] = useMutation(UPDATE_MODULE_ORDER)
23
+
24
+ const updateModulesOrder = useCallback(async (newOrder) => {
25
+ // Enviar la actualización a la API (GraphQL)
26
+ try {
27
+ await updateModuleOrderMutation({
28
+ variables: { input: newOrder.map(({ mId, mPriority }) => ({ mId, mPriority })) }
29
+ })
30
+ } catch (error) {
31
+ console.error('Error updating module order:', error)
32
+ throw new Error('Failed to update module order')
33
+ }
34
+ }, [updateModuleOrderMutation])
35
+
36
+ return [updateModulesOrder]
37
+ }
@@ -45,10 +45,10 @@ export const useUpsertGoal = ({
45
45
  cache.modify({
46
46
  fields: {
47
47
  getStore (dataOld = []) {
48
- return cache.writeQuery({
49
- query: GET_ONE_STORE,
50
- data: dataOld
51
- })
48
+ return {
49
+ ...dataOld,
50
+ dailyGoal: upsertGoal.data.dailyGoal
51
+ }
52
52
  }
53
53
  }
54
54
  })