npm-pkg-hook 1.1.0 → 1.1.2

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.
Files changed (69) hide show
  1. package/.eslintrc.js +132 -132
  2. package/next.config.js +0 -1
  3. package/package.json +46 -43
  4. package/src/config/client/errors.js +2 -1
  5. package/src/hooks/getSession/index.js +18 -0
  6. package/src/hooks/index.js +27 -7
  7. package/src/hooks/useAnimationFrame/index.js +45 -0
  8. package/src/hooks/useAnimationText/index.jsx +11 -13
  9. package/src/hooks/useCatWithProduct/index.js +37 -4
  10. package/src/hooks/useCatWithProduct/queries.js +0 -16
  11. package/src/hooks/useCategoriesProduct/index.js +12 -0
  12. package/src/hooks/useCategoriesProduct/queries.js +16 -0
  13. package/src/hooks/useChartData/index.js +182 -154
  14. package/src/hooks/useCheckbox/index.js +5 -1
  15. package/src/hooks/useClients/index.js +17 -8
  16. package/src/hooks/useCreateProduct/index.js +95 -65
  17. package/src/hooks/useDeleteSubProductOptional/index.js +30 -0
  18. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -0
  19. package/src/hooks/useDessert/helpers/index.js +51 -0
  20. package/src/hooks/useDessert/index.js +319 -121
  21. package/src/hooks/useDevices/index.js +36 -0
  22. package/src/hooks/useDevices/queries.js +19 -0
  23. package/src/hooks/useDrag/index.js +1 -1
  24. package/src/hooks/useDropzone/index.js +79 -0
  25. package/src/hooks/useDynamicAuth/index.js +13 -0
  26. package/src/hooks/useDynamicAuth/queries.js +24 -0
  27. package/src/hooks/useEmployee/index.js +11 -8
  28. package/src/hooks/useFingerprintjs/index.js +176 -0
  29. package/src/hooks/useFormTools/index.js +1 -1
  30. package/src/hooks/useFullScreenMode/index.js +8 -9
  31. package/src/hooks/useGenerateNumberArray/index.js +17 -0
  32. package/src/hooks/useImagesStore/index.js +176 -143
  33. package/src/hooks/useImagesStore/queries.js +1 -28
  34. package/src/hooks/useKeypress/index.js +7 -1
  35. package/src/hooks/useLocalSorage/index.js +1 -1
  36. package/src/hooks/useLogout/index.js +22 -25
  37. package/src/hooks/useManageQueryParams/index.js +37 -0
  38. package/src/hooks/useProductsFood/queriesStore.js +3 -16
  39. package/src/hooks/useProductsFood/usetagsProducts.js +30 -5
  40. package/src/hooks/useProviders/index.js +3 -0
  41. package/src/hooks/useProviders/queries.js +31 -0
  42. package/src/hooks/useProviders/useProvidersCreateStore/index.js +13 -0
  43. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -0
  44. package/src/hooks/useProvidersStore/index.js +24 -0
  45. package/src/hooks/useProvidersStore/queries.js +31 -0
  46. package/src/hooks/useRatingData/index.js +53 -0
  47. package/src/hooks/useRatingData/queries.js +18 -0
  48. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -0
  49. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -0
  50. package/src/hooks/useReport/index.js +16 -7
  51. package/src/hooks/useReport/queries.js +47 -32
  52. package/src/hooks/useSales/index.js +53 -22
  53. package/src/hooks/useSales/queries.js +48 -38
  54. package/src/hooks/useSales/useGetAllSales/index.js +25 -0
  55. package/src/hooks/useSales/useGetSale.js +16 -2
  56. package/src/hooks/useSchedule/index.js +36 -0
  57. package/src/hooks/useSchedule/queries.js +35 -0
  58. package/src/hooks/useScheduleData/index.js +171 -0
  59. package/src/hooks/useScroll/index.js +57 -0
  60. package/src/hooks/useScrollRotate/index.js +14 -0
  61. package/src/hooks/useStatusOpenStore/helpers/index.js +102 -0
  62. package/src/hooks/useStatusOpenStore/index.js +173 -0
  63. package/src/hooks/useUpdateExistingOrders/index.js +8 -8
  64. package/src/hooks/useUser/index.js +7 -2
  65. package/src/hooks/useUser/queries.js +40 -0
  66. package/src/index.jsx +3 -1
  67. package/.vscode/extensions.json +0 -6
  68. package/.vscode/settings.json +0 -8
  69. package/src/hooks/useSchedule/index.jsx +0 -23
@@ -0,0 +1,79 @@
1
+ export const useDropzone = (
2
+ onDrop,
3
+ draggingStyle = { border: 'dashed grey 3px' },
4
+ dragOverStyle = {
5
+ border: 'dashed grey 3px'
6
+ }
7
+ ) => {
8
+ const ref = useRef(null)
9
+ const [cleanup, setCleanup] = useState(false)
10
+ const [isDragging, setDragging] = useState(false)
11
+ const [dragOver, setDragOver] = useState(false)
12
+ const handle = useMemo(dragHandler, [])
13
+
14
+ const eventListeners = {
15
+ dragenter: e => {return handle.dragEnter(e, () => {
16
+ if (!dragOver) setDragOver(true)
17
+ })},
18
+ dragleave: e => {return handle.dragLeave(e, () => {
19
+ setDragOver(false)
20
+ })},
21
+ dragover: handle.dragBegin,
22
+ drop: e => {return handle.drop(e, files => {
23
+ if (typeof onDrop === 'function') onDrop(files, e)
24
+ setDragOver(false)
25
+ setDragging(false)
26
+ })}
27
+ }
28
+
29
+ const windowListeners = {
30
+ dragenter: e => {return handle.body.dragEnter(e, () => {
31
+ if (!isDragging) setDragging(true)
32
+ })},
33
+ dragleave: e => {return handle.body.dragLeave(e, () => {
34
+ // eslint-disable-next-line
35
+ if (isDragging) setDragging(false)
36
+ })},
37
+ dragend: () => {
38
+ // eslint-disable-next-line
39
+ },
40
+ drop: e => {return handle.body.drop(e, () => {
41
+ setDragging(false)
42
+ setDragOver(false)
43
+ })}
44
+ }
45
+
46
+ useEffect(() => {
47
+ if (ref.current) {
48
+ const { current } = ref
49
+ Object.keys(eventListeners).forEach(key => {return current.addEventListener(key, eventListeners[key])}
50
+ )
51
+ Object.keys(windowListeners).forEach(key => {return window.addEventListener(key, windowListeners[key])}
52
+ )
53
+ setCleanup(true)
54
+ }
55
+
56
+ return () => {
57
+ if (cleanup) {
58
+ const { current } = ref
59
+ if (current) {
60
+ Object.keys(eventListeners).forEach(key => {return current.removeEventListener(key, eventListeners[key])}
61
+ )
62
+ }
63
+ Object.keys(windowListeners).forEach(key => {return window.removeEventListener(key, windowListeners[key])}
64
+ )
65
+ }
66
+ }
67
+ }, [ref, windowListeners, cleanup, eventListeners, isDragging, dragOver])
68
+
69
+ const dropProps = {
70
+ ref,
71
+ style:
72
+ isDragging || dragOver
73
+ ? dragOver
74
+ ? dragOverStyle
75
+ : draggingStyle
76
+ : undefined
77
+ }
78
+ return { isDragging, dragOver, dropProps }
79
+ }
@@ -0,0 +1,13 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { useState } from 'react'
3
+ import { GET_ONE_DYNAMIC_PASS } from './queries'
4
+
5
+ export const useDynamicAuth = () => {
6
+ const [dynamicPass, setDynamicPass] = useState({})
7
+ const { loading, error } = useQuery(GET_ONE_DYNAMIC_PASS, {
8
+ onCompleted: (res) => {
9
+ setDynamicPass(res.getAOneDynamicPassword)
10
+ }
11
+ })
12
+ return [dynamicPass, { loading, error }]
13
+ }
@@ -0,0 +1,24 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const CREATE_ONE_DYNAMIC_PASS = gql`
4
+ mutation registerDynamicPassword($input: IDynamicPassword) {
5
+ registerDynamicPassword(input: $input) {
6
+ success
7
+ message
8
+ }
9
+ }
10
+ `
11
+ export const GET_ONE_DYNAMIC_PASS = gql`
12
+ query getAOneDynamicPassword {
13
+ getAOneDynamicPassword {
14
+ dPassId
15
+ id
16
+ idStore
17
+ keyPassDynamic
18
+ deviceName
19
+ dState
20
+ DatCre
21
+ DatMod
22
+ }
23
+ }
24
+ `
@@ -1,13 +1,16 @@
1
1
  import { useQuery } from '@apollo/client'
2
- import { useEffect, useState } from 'react'
3
2
  import { GET_EMPLOYEES } from './queries'
4
3
 
5
4
  export const useEmployee = () => {
6
- const [clientes, setClients] = useState([])
7
- const [more, setMore] = useState(100)
8
- const { data, loading, error, fetchMore } = useQuery(GET_EMPLOYEES)
9
- useEffect(() => {
10
- setClients(data)
11
- }, [clientes, data])
12
- return [clientes?.employees, { loading, error, fetchMore, setMore, more }]
5
+ const { data, loading, error, fetchMore } = useQuery(GET_EMPLOYEES, {
6
+ onError: (error) => {
7
+ console.error(error)
8
+ }
9
+ })
10
+ const employees = data?.employees || []
11
+ return [employees, {
12
+ loading,
13
+ error,
14
+ fetchMore
15
+ }]
13
16
  }
@@ -0,0 +1,176 @@
1
+ import md5 from 'md5'
2
+
3
+ async function getCPUInfo() {
4
+ if (navigator.hardwareConcurrency) {
5
+ try {
6
+ const logicalCores = navigator.hardwareConcurrency;
7
+ const agent = window.navigator.userAgent;
8
+ const hyperThreaded = /Intel|Apple/.test(agent) && /Win64|Linux x86_64|MacIntel/.test(agent);
9
+
10
+ // Ajustar el número de núcleos lógicos si se sospecha hiperprocesamiento
11
+ const physicalCores = hyperThreaded ? logicalCores / 2 : logicalCores;
12
+
13
+ const cpuInfo = {
14
+ logicalCores: logicalCores,
15
+ physicalCores: physicalCores,
16
+ hyperThreaded: hyperThreaded
17
+ };
18
+ return JSON.stringify(cpuInfo);
19
+ } catch (error) {
20
+ console.error('Error al obtener información de la CPU:', error);
21
+ return 'cpu-info-error';
22
+ }
23
+ } else {
24
+ return 'cpu-info-not-available';
25
+ }
26
+ }
27
+
28
+ async function generateFingerprint() {
29
+ const canvas = document.createElement('canvas');
30
+ const context = canvas.getContext('2d');
31
+ const audioContext = new (window.AudioContext || window.webkitAudioContext)();
32
+
33
+ const userAgent = navigator.userAgent;
34
+ const language = navigator.language;
35
+ const colorDepth = window.screen.colorDepth;
36
+ const availableScreenHeight = window.screen.availHeight;
37
+ const platform = navigator.platform;
38
+ const cpuClass = navigator.cpuClass || 'unknown';
39
+
40
+ const canvasFingerprint = await generateCanvasFingerprint(canvas);
41
+ const audioFingerprint = await generateAudioFingerprint(audioContext);
42
+
43
+ const cpuInfo = await getCPUInfo();
44
+ const webGLInfo = await getWebGLInfo();
45
+ const fonts = getInstalledFonts();
46
+ const touchscreenInfo = getTouchscreenInfo();
47
+
48
+ const fingerprintData = {
49
+ browser: {
50
+ userAgent,
51
+ language,
52
+ colorDepth,
53
+ availableScreenHeight,
54
+ plugins: Array.from(navigator.plugins).map(plugin => plugin.name).join(','),
55
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
56
+ hardwareConcurrency: cpuInfo.logicalCores || 'unknown',
57
+ platformVersion: navigator.platformVersion || 'unknown',
58
+ },
59
+ device: {
60
+ platform,
61
+ cpuClass,
62
+ },
63
+ canvas: canvasFingerprint,
64
+ audio: audioFingerprint,
65
+ cpu: cpuInfo,
66
+ webgl: webGLInfo,
67
+ fonts,
68
+ touchscreen: touchscreenInfo,
69
+ };
70
+
71
+ const fingerprint = JSON.stringify(fingerprintData);
72
+ const uniqueID = md5(fingerprint);
73
+
74
+ return uniqueID;
75
+ }
76
+
77
+ // Función para generar huella digital del audio
78
+ async function generateAudioFingerprint(audioContext) {
79
+ if (audioContext) {
80
+ try {
81
+ await audioContext.resume();
82
+
83
+ // Obtén propiedades del audio que puedas obtener en modo incógnito
84
+ const audioProperties = {
85
+ isAudioContextAvailable: true,
86
+ // Agrega más propiedades relevantes aquí
87
+ };
88
+
89
+ return audioProperties;
90
+ } catch (error) {
91
+ console.error('Error al generar huella digital de audio:', error);
92
+ }
93
+ }
94
+
95
+ return { isAudioContextAvailable: false };
96
+ }
97
+
98
+ // Función para generar huella digital del canvas
99
+ async function generateCanvasFingerprint(canvas) {
100
+ if (canvas) {
101
+ try {
102
+ canvas.width = 200;
103
+ canvas.height = 200;
104
+ const context = canvas.getContext('2d');
105
+ context.clearRect(0, 0, canvas.width, canvas.height);
106
+ context.fillStyle = '#f60';
107
+ context.fillRect(125, 1, 62, 20);
108
+ context.fillStyle = '#069';
109
+ context.font = '16pt Arial';
110
+ context.fillText('Cwm fjordbank glyphs vext quiz', 125, 20);
111
+
112
+ // Obtén más propiedades del canvas que puedas obtener en modo incógnito
113
+ const canvasProperties = {
114
+ width: canvas.width,
115
+ height: canvas.height,
116
+ // Agrega más propiedades relevantes aquí
117
+ };
118
+
119
+ return canvasProperties;
120
+ } catch (error) {
121
+ console.error('Error al generar huella digital del canvas:', error);
122
+ }
123
+ }
124
+
125
+ return { width: 0, height: 0 };
126
+ }
127
+
128
+
129
+
130
+ async function getWebGLInfo() {
131
+ if ('WebGLRenderingContext' in window) {
132
+ const canvas = document.createElement('canvas');
133
+ const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
134
+
135
+ if (gl) {
136
+ const renderer = gl.getParameter(gl.RENDERER);
137
+ const version = gl.getParameter(gl.VERSION);
138
+
139
+ // Obtener más información sobre las capacidades WebGL si es necesario
140
+
141
+ return `${renderer}-${version}`;
142
+ }
143
+ }
144
+
145
+ return 'webgl-info-not-supported';
146
+ }
147
+
148
+ function getInstalledFonts() {
149
+ const fonts = [];
150
+
151
+ if ('fonts' in document) {
152
+ document.fonts.forEach(font => {
153
+ fonts.push(font.family);
154
+ });
155
+ }
156
+
157
+ return fonts.join(',');
158
+ }
159
+
160
+ function getTouchscreenInfo() {
161
+ if ('maxTouchPoints' in navigator) {
162
+ const maxTouchPoints = navigator.maxTouchPoints;
163
+ const touchEvent = 'ontouchstart' in window ? 'true' : 'false';
164
+
165
+ return `${maxTouchPoints}-${touchEvent}`;
166
+ }
167
+
168
+ return 'touchscreen-info-not-supported';
169
+ }
170
+
171
+
172
+ export async function fingerprintJs() {
173
+ const fingerprint = await generateFingerprint();
174
+ const uniqueID = md5(fingerprint)
175
+ return uniqueID;
176
+ }
@@ -75,7 +75,7 @@ export const useFormTools = ({ sendNotification = () => { } } = {}) => {
75
75
 
76
76
  // Ejecuta la accion si es válido
77
77
  if (!errSub && action) {
78
- action().then(res => {
78
+ action()?.then(res => {
79
79
  if (res) {
80
80
  sendNotification({
81
81
  message: msgSuccess || 'Operación exitosa',
@@ -1,7 +1,10 @@
1
- import React, { useState, useRef, useEffect } from 'react'
2
- import styled from 'styled-components'
1
+ import React, {
2
+ useState,
3
+ useRef,
4
+ useEffect
5
+ } from 'react'
3
6
 
4
- const useFullscreenMode = () => {
7
+ export const useFullScreenMode = () => {
5
8
  const [isFullscreen, setFullscreen] = useState(false)
6
9
  const elementRef = useRef()
7
10
 
@@ -56,11 +59,7 @@ const useFullscreenMode = () => {
56
59
  }
57
60
 
58
61
  const ToggleIcon = (
59
- <Button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
62
+ <button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</button>
60
63
  )
61
64
  return [elementRef, ToggleIcon] //Icon, ref
62
- }
63
- const Button = styled.button`
64
-
65
- `
66
- export default useFullscreenMode
65
+ }
@@ -0,0 +1,17 @@
1
+ const addButtonValues = (values, max) => {
2
+ const value1 = values.splice(Math.floor(Math.random() * (max - 0)) + 0, 1)
3
+ return { max: max - 2, values: [value1] }
4
+ }
5
+
6
+ export const useGenerateNumberArray = () => {
7
+ const values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
8
+ let max = 9
9
+ const buttons = Array.from(Array(10)).map(() => {
10
+ return Array.from(Array(1)).map(() => {
11
+ const buttonValues = addButtonValues(values, max)
12
+ max = buttonValues.max
13
+ return buttonValues.values
14
+ })
15
+ })
16
+ return buttons
17
+ }