npm-pkg-hook 1.1.5 → 1.1.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.
Files changed (140) hide show
  1. package/.eslintrc.js +19 -113
  2. package/.eslintrc.json +127 -108
  3. package/next.config.js +2 -5
  4. package/package.json +27 -24
  5. package/src/config/client/errors.js +14 -14
  6. package/src/config/client/index.js +1 -1
  7. package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
  8. package/src/hooks/getCategoriesWithProduct/index.js +62 -0
  9. package/src/hooks/getSession/index.js +18 -18
  10. package/src/hooks/index.js +13 -9
  11. package/src/hooks/useAcumulateDate/index.js +1 -1
  12. package/src/hooks/useAnimationFrame/index.js +45 -45
  13. package/src/hooks/useAsideCart/helpers/index.js +22 -0
  14. package/src/hooks/useAsideCart/index.js +156 -0
  15. package/src/hooks/useAsideCart/queries.js +10 -0
  16. package/src/hooks/useBanner/index.js +11 -11
  17. package/src/hooks/useCart/index.js +2 -0
  18. package/src/hooks/useCart/queries.js +164 -0
  19. package/src/hooks/useCart/useCart/helpers/index.js +75 -0
  20. package/src/hooks/useCart/useCart/index.js +411 -0
  21. package/src/hooks/useCart/useGetCart/index.js +31 -0
  22. package/src/hooks/useCatWithProduct/index.js +15 -15
  23. package/src/hooks/useCatWithProduct/queries.js +1 -1
  24. package/src/hooks/useCatWithProductClient/index.js +48 -0
  25. package/src/hooks/useCatWithProductClient/queries.js +55 -0
  26. package/src/hooks/useCategoriesProduct/index.js +12 -12
  27. package/src/hooks/useCategoriesProduct/queries.js +16 -16
  28. package/src/hooks/useCategoryInStore/index.js +39 -36
  29. package/src/hooks/useCategoryInStore/queries.js +78 -78
  30. package/src/hooks/useCategoryStore/index.js +2 -2
  31. package/src/hooks/useChartData/index.js +159 -156
  32. package/src/hooks/useChartData/useChartData/index.js +199 -197
  33. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
  34. package/src/hooks/useCheckbox/index.js +115 -115
  35. package/src/hooks/useClients/index.js +12 -14
  36. package/src/hooks/useClients/queries.js +1 -1
  37. package/src/hooks/useConnection/index.js +20 -21
  38. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
  39. package/src/hooks/useCreateProduct/index.js +22 -19
  40. package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
  41. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
  42. package/src/hooks/useDessert/helpers/index.js +51 -51
  43. package/src/hooks/useDessert/index.js +56 -65
  44. package/src/hooks/useDevices/index.js +35 -36
  45. package/src/hooks/useDevices/queries.js +19 -19
  46. package/src/hooks/useDropzone/index.js +94 -79
  47. package/src/hooks/useDynamicAuth/index.js +13 -13
  48. package/src/hooks/useDynamicAuth/queries.js +24 -24
  49. package/src/hooks/useEmployee/queries.js +1 -1
  50. package/src/hooks/useEvent/index.js +33 -33
  51. package/src/hooks/useFavoriteStores/index.js +19 -0
  52. package/src/hooks/useFavoriteStores/queries.js +47 -0
  53. package/src/hooks/useFetchJson/index.js +25 -25
  54. package/src/hooks/useFingerprintjs/index.js +172 -176
  55. package/src/hooks/useFormTools/index.js +12 -11
  56. package/src/hooks/useFormatDate/index.js +20 -21
  57. package/src/hooks/useFormatNumberPhone/index.js +9 -9
  58. package/src/hooks/useFullScreenMode/index.js +65 -65
  59. package/src/hooks/useGenerateNumberArray/index.js +17 -17
  60. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
  61. package/src/hooks/useGetFoodRecomended/index.js +33 -0
  62. package/src/hooks/useGetFoodRecomended/queries.js +47 -0
  63. package/src/hooks/useGetMinPrice/index.js +8 -0
  64. package/src/hooks/useGetMinPrice/queries.js +7 -0
  65. package/src/hooks/useGetOneStoreRating/index.js +40 -0
  66. package/src/hooks/useGetOneStoreRating/queries.js +18 -0
  67. package/src/hooks/useGoogleLogin/index.js +160 -161
  68. package/src/hooks/useHover/index.js +29 -29
  69. package/src/hooks/useImageOptimization/index.js +15 -15
  70. package/src/hooks/useImageWeight/index.js +18 -19
  71. package/src/hooks/useImagesStore/index.js +139 -140
  72. package/src/hooks/useImagesStore/queries.js +19 -18
  73. package/src/hooks/useInnerHtml/index.js +39 -38
  74. package/src/hooks/useIntersection/index.js +4 -4
  75. package/src/hooks/useKeypress/index.js +28 -28
  76. package/src/hooks/useLazyScript/index.js +35 -36
  77. package/src/hooks/useLocalSorage/index.js +2 -2
  78. package/src/hooks/useLogout/index.js +23 -23
  79. package/src/hooks/useManageQueryParams/index.js +36 -37
  80. package/src/hooks/useMobile/index.js +39 -38
  81. package/src/hooks/useMutateHeight/index.js +15 -16
  82. package/src/hooks/useOrderClient/index.js +5 -0
  83. package/src/hooks/useOrders/index.js +10 -16
  84. package/src/hooks/useOrders/queries.js +1 -1
  85. package/src/hooks/useProductsFood/index.js +32 -32
  86. package/src/hooks/useProductsFood/queriesStore.js +49 -48
  87. package/src/hooks/useProductsFood/useEditProduct.js +2 -4
  88. package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
  89. package/src/hooks/useProviders/index.js +3 -3
  90. package/src/hooks/useProviders/queries.js +31 -31
  91. package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
  92. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
  93. package/src/hooks/useProvidersStore/index.js +24 -24
  94. package/src/hooks/useProvidersStore/queries.js +31 -31
  95. package/src/hooks/useRatingArrayData/index.js +54 -0
  96. package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
  97. package/src/hooks/useReactToPrint/index.js +1120 -1098
  98. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
  99. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
  100. package/src/hooks/useReport/index.js +9 -9
  101. package/src/hooks/useReport/queries.js +1 -1
  102. package/src/hooks/useRestaurant/index.js +19 -19
  103. package/src/hooks/useRestaurant/queries.js +80 -80
  104. package/src/hooks/useSales/index.js +476 -451
  105. package/src/hooks/useSales/queries.js +14 -15
  106. package/src/hooks/useSales/useGetAllSales/index.js +25 -25
  107. package/src/hooks/useSales/useTotalSales.js +18 -18
  108. package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
  109. package/src/hooks/useSaveAvailableProduct/index.js +16 -16
  110. package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
  111. package/src/hooks/useSchedule/index.js +33 -36
  112. package/src/hooks/useSchedule/index.jsx +22 -22
  113. package/src/hooks/useSchedule/queries.js +34 -35
  114. package/src/hooks/useScheduleData/index.js +123 -171
  115. package/src/hooks/useScroll/index.js +56 -57
  116. package/src/hooks/useScrollRotate/index.js +16 -14
  117. package/src/hooks/useSetSession/index.js +16 -16
  118. package/src/hooks/useSetState/index.js +3 -3
  119. package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
  120. package/src/hooks/useStatusOpenStore/index.js +172 -173
  121. package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
  122. package/src/hooks/useStatusOrdersClient/index.js +17 -0
  123. package/src/hooks/useStatusOrdersClient/queries.js +80 -0
  124. package/src/hooks/useStore/index.js +40 -25
  125. package/src/hooks/useStore/queries.js +162 -136
  126. package/src/hooks/useStoreCalendar/index.js +5 -7
  127. package/src/hooks/useStoreContacts/index.js +16 -16
  128. package/src/hooks/useStoreContacts/queries.js +1 -1
  129. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  130. package/src/hooks/useUpdateCart/index.js +34 -28
  131. package/src/hooks/useUpdateExistingOrders/index.js +35 -35
  132. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
  133. package/src/hooks/useUser/index.js +1 -1
  134. package/src/hooks/useUser/queries.js +1 -1
  135. package/src/hooks/useWindowSize/index.js +38 -38
  136. package/src/mock/dessert/index.js +16 -16
  137. package/src/mock/index.js +1 -2
  138. package/src/utils/index.js +42 -45
  139. package/src/hooks/useRatingData/index.js +0 -53
  140. package/src/hooks/useSalesClient/index.js +0 -1
@@ -1,176 +1,172 @@
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
- }
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,
15
+ physicalCores,
16
+ 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 audioContext = new (window.AudioContext || window.webkitAudioContext)()
31
+
32
+ const userAgent = navigator.userAgent
33
+ const language = navigator.language
34
+ const colorDepth = window.screen.colorDepth
35
+ const availableScreenHeight = window.screen.availHeight
36
+ const platform = navigator.platform
37
+ const cpuClass = navigator.cpuClass || 'unknown'
38
+
39
+ const canvasFingerprint = await generateCanvasFingerprint(canvas)
40
+ const audioFingerprint = await generateAudioFingerprint(audioContext)
41
+
42
+ const cpuInfo = await getCPUInfo()
43
+ const webGLInfo = await getWebGLInfo()
44
+ const fonts = getInstalledFonts()
45
+ const touchscreenInfo = getTouchscreenInfo()
46
+
47
+ const fingerprintData = {
48
+ browser: {
49
+ userAgent,
50
+ language,
51
+ colorDepth,
52
+ availableScreenHeight,
53
+ plugins: Array.from(navigator.plugins).map(plugin => plugin.name).join(','),
54
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
55
+ hardwareConcurrency: cpuInfo.logicalCores || 'unknown',
56
+ platformVersion: navigator.platformVersion || 'unknown'
57
+ },
58
+ device: {
59
+ platform,
60
+ cpuClass
61
+ },
62
+ canvas: canvasFingerprint,
63
+ audio: audioFingerprint,
64
+ cpu: cpuInfo,
65
+ webgl: webGLInfo,
66
+ fonts,
67
+ touchscreen: touchscreenInfo
68
+ }
69
+
70
+ const fingerprint = JSON.stringify(fingerprintData)
71
+ const uniqueID = md5(fingerprint)
72
+
73
+ return uniqueID
74
+ }
75
+
76
+ // Función para generar huella digital del audio
77
+ async function generateAudioFingerprint (audioContext) {
78
+ if (audioContext) {
79
+ try {
80
+ await audioContext.resume()
81
+
82
+ // Obtén propiedades del audio que puedas obtener en modo incógnito
83
+ const audioProperties = {
84
+ isAudioContextAvailable: true
85
+ // Agrega más propiedades relevantes aquí
86
+ }
87
+
88
+ return audioProperties
89
+ } catch (error) {
90
+ console.error('Error al generar huella digital de audio:', error)
91
+ }
92
+ }
93
+
94
+ return { isAudioContextAvailable: false }
95
+ }
96
+
97
+ // Función para generar huella digital del canvas
98
+ async function generateCanvasFingerprint (canvas) {
99
+ if (canvas) {
100
+ try {
101
+ canvas.width = 200
102
+ canvas.height = 200
103
+ const context = canvas.getContext('2d')
104
+ context.clearRect(0, 0, canvas.width, canvas.height)
105
+ context.fillStyle = '#f60'
106
+ context.fillRect(125, 1, 62, 20)
107
+ context.fillStyle = '#069'
108
+ context.font = '16pt Arial'
109
+ context.fillText('Cwm fjordbank glyphs vext quiz', 125, 20)
110
+
111
+ // Obtén más propiedades del canvas que puedas obtener en modo incógnito
112
+ const canvasProperties = {
113
+ width: canvas.width,
114
+ height: canvas.height
115
+ // Agrega más propiedades relevantes aquí
116
+ }
117
+
118
+ return canvasProperties
119
+ } catch (error) {
120
+ console.error('Error al generar huella digital del canvas:', error)
121
+ }
122
+ }
123
+
124
+ return { width: 0, height: 0 }
125
+ }
126
+
127
+ async function getWebGLInfo () {
128
+ if ('WebGLRenderingContext' in window) {
129
+ const canvas = document.createElement('canvas')
130
+ const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl')
131
+
132
+ if (gl) {
133
+ const renderer = gl.getParameter(gl.RENDERER)
134
+ const version = gl.getParameter(gl.VERSION)
135
+
136
+ // Obtener más información sobre las capacidades WebGL si es necesario
137
+
138
+ return `${renderer}-${version}`
139
+ }
140
+ }
141
+
142
+ return 'webgl-info-not-supported'
143
+ }
144
+
145
+ function getInstalledFonts () {
146
+ const fonts = []
147
+
148
+ if ('fonts' in document) {
149
+ document.fonts.forEach(font => {
150
+ fonts.push(font.family)
151
+ })
152
+ }
153
+
154
+ return fonts.join(',')
155
+ }
156
+
157
+ function getTouchscreenInfo () {
158
+ if ('maxTouchPoints' in navigator) {
159
+ const maxTouchPoints = navigator.maxTouchPoints
160
+ const touchEvent = 'ontouchstart' in window ? 'true' : 'false'
161
+
162
+ return `${maxTouchPoints}-${touchEvent}`
163
+ }
164
+
165
+ return 'touchscreen-info-not-supported'
166
+ }
167
+
168
+ export async function fingerprintJs () {
169
+ const fingerprint = await generateFingerprint()
170
+ const uniqueID = md5(fingerprint)
171
+ return uniqueID
172
+ }
@@ -40,8 +40,8 @@ export const useFormTools = ({ sendNotification = () => { } } = {}) => {
40
40
  event,
41
41
  msgError = '',
42
42
  msgSuccess,
43
- action = () => { return },
44
- actionAfterSuccess = () => { return }
43
+ action = () => { },
44
+ actionAfterSuccess = () => { }
45
45
  }) => {
46
46
  event.preventDefault()
47
47
  setCalledSubmit(true)
@@ -60,8 +60,8 @@ export const useFormTools = ({ sendNotification = () => { } } = {}) => {
60
60
  }
61
61
  if (errors) {
62
62
  setErrorSubmit(true)
63
- return setForcedError({ ...errorForm })
64
- }
63
+ return setForcedError({ ...errorForm })
64
+ }
65
65
 
66
66
  if (errSub) return setErrorSubmit(errSub)
67
67
 
@@ -80,20 +80,21 @@ export const useFormTools = ({ sendNotification = () => { } } = {}) => {
80
80
  sendNotification({
81
81
  message: msgSuccess || 'Operación exitosa',
82
82
  description: 'Operación exitosa',
83
- backgroundColor: 'success' })
83
+ backgroundColor: 'success'
84
+ })
84
85
  !!actionAfterSuccess && actionAfterSuccess()
85
- }
86
-
87
- }).catch(e => {return sendNotification({ title: msgError || e?.message || 'Ha ocurrido un error', backgroundColor: 'error' })})
86
+ }
87
+ }).catch(e => { return sendNotification({ title: msgError || e?.message || 'Ha ocurrido un error', backgroundColor: 'error' }) })
88
88
  }
89
89
 
90
90
  setErrorSubmit(errSub)
91
91
  }
92
92
 
93
- useEffect(() => {return setCalledSubmit(false)}, [calledSubmit])
93
+ useEffect(() => { return setCalledSubmit(false) }, [calledSubmit])
94
94
  useEffect(() => {
95
- return setCalledSubmit(false)},
95
+ return setCalledSubmit(false)
96
+ },
96
97
  [])
97
98
 
98
99
  return [handleChange, handleSubmit, handleForcedData, { dataForm, errorForm, errorSubmit, calledSubmit, setForcedError }]
99
- }
100
+ }
@@ -1,23 +1,23 @@
1
1
  export const useFormatDate = ({
2
- date,
3
- local = 'ES'
2
+ date,
3
+ local = 'ES'
4
4
  } = {}) => {
5
- const dateToFormat = new Date(date ?? Date.now())
6
- const fullDate = dateToFormat.toLocaleDateString(local, { year: 'numeric', month: '2-digit', day: '2-digit' })
7
- const day = fullDate.split('/')[0]
8
- const month = fullDate.split('/')[1]
9
- const year = fullDate.split('/')[2]
10
- const yearMonthDay = dateToFormat.toLocaleDateString('en-CA')
11
- const numberDay = dateToFormat.getDay()
12
- const shortDayName = dateToFormat.toLocaleDateString(local, { weekday: 'short' })
13
- const longDayName = dateToFormat.toLocaleDateString(local, { weekday: 'long' })
14
- const hourMinutes12 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit' })
15
- const hourMinutes24 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit', hour12: false })
16
- const handleHourPmAM = (hour) => {
17
- const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
18
- return hour ? hourPmAm : ''
19
- }
20
- return {
5
+ const dateToFormat = new Date(date ?? Date.now())
6
+ const fullDate = dateToFormat.toLocaleDateString(local, { year: 'numeric', month: '2-digit', day: '2-digit' })
7
+ const day = fullDate.split('/')[0]
8
+ const month = fullDate.split('/')[1]
9
+ const year = fullDate.split('/')[2]
10
+ const yearMonthDay = dateToFormat.toLocaleDateString('en-CA')
11
+ const numberDay = dateToFormat.getDay()
12
+ const shortDayName = dateToFormat.toLocaleDateString(local, { weekday: 'short' })
13
+ const longDayName = dateToFormat.toLocaleDateString(local, { weekday: 'long' })
14
+ const hourMinutes12 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit' })
15
+ const hourMinutes24 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit', hour12: false })
16
+ const handleHourPmAM = (hour) => {
17
+ const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
18
+ return hour ? hourPmAm : ''
19
+ }
20
+ return {
21
21
  day,
22
22
  fullDate,
23
23
  hourMinutes12,
@@ -28,7 +28,6 @@ export const useFormatDate = ({
28
28
  shortDayName,
29
29
  month,
30
30
  year,
31
- handleHourPmAM,
32
- }
31
+ handleHourPmAM
32
+ }
33
33
  }
34
-
@@ -4,12 +4,12 @@
4
4
  * @returns {any}
5
5
  */
6
6
  export const formatPhoneNumber = (phoneNumber) => {
7
- const cleaned = ('' + phoneNumber).replace(/\D/g, '');
8
- const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
9
- if (match) {
10
- return `(${match[1]}) ${match[2]}-${match[3]}`;
11
- }
12
- return phoneNumber;
7
+ const cleaned = ('' + phoneNumber).replace(/\D/g, '')
8
+ const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/)
9
+ if (match) {
10
+ return `(${match[1]}) ${match[2]}-${match[3]}`
11
+ }
12
+ return phoneNumber
13
13
  }
14
14
 
15
15
  /**
@@ -18,6 +18,6 @@ export const formatPhoneNumber = (phoneNumber) => {
18
18
  * @returns {any}
19
19
  */
20
20
  export const validatePhoneNumber = (phoneNumber) => {
21
- const regex = /^\(\d{3}\) \d{3}-\d{4}$/;
22
- return regex.test(phoneNumber);
23
- };
21
+ const regex = /^\(\d{3}\) \d{3}-\d{4}$/
22
+ return regex.test(phoneNumber)
23
+ }
@@ -1,65 +1,65 @@
1
- import React, { useState, useRef, useEffect } from 'react'
2
- import styled from 'styled-components'
3
-
4
- export const useFullscreenMode = () => {
5
- const [isFullscreen, setFullscreen] = useState(false)
6
- const elementRef = useRef()
7
-
8
- useEffect(() => {
9
- const changeHandler = () => {return setFullscreen(mode => {return !mode})}
10
-
11
- document.addEventListener('fullscreenchange', changeHandler, false)
12
- document.addEventListener('mozfullscreenchange', changeHandler, false)
13
- document.addEventListener('MSFullScreenChange', changeHandler, false)
14
- document.addEventListener(
15
- 'webkitfullscreenchange',
16
- changeHandler,
17
- false
18
- )
19
-
20
- return () => {
21
- document.removeEventListener('fullscreenchange', changeHandler)
22
- document.removeEventListener('mozfullscreenchange', changeHandler)
23
- document.removeEventListener('MSFullScreenChange', changeHandler)
24
- document.removeEventListener(
25
- 'webkitfullscreenchange',
26
- changeHandler
27
- )
28
- }
29
- }, [])
30
-
31
- const goFullscreen = () => {
32
- if (elementRef.current.requestFullscreen) {
33
- elementRef.current.requestFullscreen()
34
- } else if (elementRef.current.mozRequestFullscreen) {
35
- //Firefox
36
- elementRef.current.mozRequestFullscreen()
37
- } else if (elementRef.current.webkitRequestFullscreen) {
38
- //Chrome, safari, opera
39
- elementRef.current.webkitRequestFullscreen()
40
- } else if (elementRef.current.msRequestFullscreen) {
41
- //IE, edge
42
- elementRef.current.msRequestFullscreen()
43
- }
44
- }
45
-
46
- const exitFullScreen = () => {
47
- if (document.exitFullscreen) {
48
- document.exitFullscreen()
49
- } else if (document.mozCancelFullScreen) {
50
- document.mozCancelFullScreen()
51
- } else if (document.webkitExitFullscreen) {
52
- document.webkitExitFullscreen()
53
- } else if (document.msExitFullscreen) {
54
- document.msExitFullscreen()
55
- }
56
- }
57
-
58
- const ToggleIcon = (
59
- <Button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
60
- )
61
- return [elementRef, ToggleIcon] //Icon, ref
62
- }
63
- const Button = styled.button`
64
-
65
- `
1
+ import React, { useState, useRef, useEffect } from 'react'
2
+ import styled from 'styled-components'
3
+
4
+ export const useFullscreenMode = () => {
5
+ const [isFullscreen, setFullscreen] = useState(false)
6
+ const elementRef = useRef()
7
+
8
+ useEffect(() => {
9
+ const changeHandler = () => { return setFullscreen(mode => { return !mode }) }
10
+
11
+ document.addEventListener('fullscreenchange', changeHandler, false)
12
+ document.addEventListener('mozfullscreenchange', changeHandler, false)
13
+ document.addEventListener('MSFullScreenChange', changeHandler, false)
14
+ document.addEventListener(
15
+ 'webkitfullscreenchange',
16
+ changeHandler,
17
+ false
18
+ )
19
+
20
+ return () => {
21
+ document.removeEventListener('fullscreenchange', changeHandler)
22
+ document.removeEventListener('mozfullscreenchange', changeHandler)
23
+ document.removeEventListener('MSFullScreenChange', changeHandler)
24
+ document.removeEventListener(
25
+ 'webkitfullscreenchange',
26
+ changeHandler
27
+ )
28
+ }
29
+ }, [])
30
+
31
+ const goFullscreen = () => {
32
+ if (elementRef.current.requestFullscreen) {
33
+ elementRef.current.requestFullscreen()
34
+ } else if (elementRef.current.mozRequestFullscreen) {
35
+ // Firefox
36
+ elementRef.current.mozRequestFullscreen()
37
+ } else if (elementRef.current.webkitRequestFullscreen) {
38
+ // Chrome, safari, opera
39
+ elementRef.current.webkitRequestFullscreen()
40
+ } else if (elementRef.current.msRequestFullscreen) {
41
+ // IE, edge
42
+ elementRef.current.msRequestFullscreen()
43
+ }
44
+ }
45
+
46
+ const exitFullScreen = () => {
47
+ if (document.exitFullscreen) {
48
+ document.exitFullscreen()
49
+ } else if (document.mozCancelFullScreen) {
50
+ document.mozCancelFullScreen()
51
+ } else if (document.webkitExitFullscreen) {
52
+ document.webkitExitFullscreen()
53
+ } else if (document.msExitFullscreen) {
54
+ document.msExitFullscreen()
55
+ }
56
+ }
57
+
58
+ const ToggleIcon = (
59
+ <Button onDoubleClick={() => { return (!isFullscreen ? goFullscreen() : exitFullScreen()) }}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
60
+ )
61
+ return [elementRef, ToggleIcon] // Icon, ref
62
+ }
63
+ const Button = styled.button`
64
+
65
+ `
@@ -1,17 +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
- }
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
+ }