npm-pkg-hook 1.1.0 → 1.1.3

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 (72) 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 +2 -169
  14. package/src/hooks/useChartData/useChartData/index.js +197 -0
  15. package/src/hooks/useChartData/useChartDataAllOrders/index.js +89 -0
  16. package/src/hooks/useCheckbox/index.js +5 -1
  17. package/src/hooks/useClients/index.js +17 -8
  18. package/src/hooks/useCreateProduct/index.js +95 -65
  19. package/src/hooks/useDeleteSubProductOptional/index.js +30 -0
  20. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -0
  21. package/src/hooks/useDessert/helpers/index.js +51 -0
  22. package/src/hooks/useDessert/index.js +319 -121
  23. package/src/hooks/useDevices/index.js +36 -0
  24. package/src/hooks/useDevices/queries.js +19 -0
  25. package/src/hooks/useDrag/index.js +1 -1
  26. package/src/hooks/useDropzone/index.js +79 -0
  27. package/src/hooks/useDynamicAuth/index.js +13 -0
  28. package/src/hooks/useDynamicAuth/queries.js +24 -0
  29. package/src/hooks/useEmployee/index.js +11 -8
  30. package/src/hooks/useFingerprintjs/index.js +176 -0
  31. package/src/hooks/useFormTools/index.js +1 -1
  32. package/src/hooks/useFullScreenMode/index.js +8 -9
  33. package/src/hooks/useGenerateNumberArray/index.js +17 -0
  34. package/src/hooks/useImagesStore/index.js +176 -143
  35. package/src/hooks/useImagesStore/queries.js +1 -28
  36. package/src/hooks/useKeypress/index.js +7 -1
  37. package/src/hooks/useLocalSorage/index.js +1 -1
  38. package/src/hooks/useLogout/index.js +22 -25
  39. package/src/hooks/useManageQueryParams/index.js +37 -0
  40. package/src/hooks/useProductsFood/queriesStore.js +3 -16
  41. package/src/hooks/useProductsFood/usetagsProducts.js +30 -5
  42. package/src/hooks/useProviders/index.js +3 -0
  43. package/src/hooks/useProviders/queries.js +31 -0
  44. package/src/hooks/useProviders/useProvidersCreateStore/index.js +13 -0
  45. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -0
  46. package/src/hooks/useProvidersStore/index.js +24 -0
  47. package/src/hooks/useProvidersStore/queries.js +31 -0
  48. package/src/hooks/useRatingData/index.js +53 -0
  49. package/src/hooks/useRatingData/queries.js +18 -0
  50. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -0
  51. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -0
  52. package/src/hooks/useReport/index.js +16 -7
  53. package/src/hooks/useReport/queries.js +47 -32
  54. package/src/hooks/useSales/index.js +53 -22
  55. package/src/hooks/useSales/queries.js +48 -38
  56. package/src/hooks/useSales/useGetAllSales/index.js +25 -0
  57. package/src/hooks/useSales/useGetSale.js +16 -2
  58. package/src/hooks/useSchedule/index.js +36 -0
  59. package/src/hooks/useSchedule/queries.js +35 -0
  60. package/src/hooks/useScheduleData/index.js +171 -0
  61. package/src/hooks/useScroll/index.js +57 -0
  62. package/src/hooks/useScrollRotate/index.js +14 -0
  63. package/src/hooks/useStatusOpenStore/helpers/index.js +102 -0
  64. package/src/hooks/useStatusOpenStore/index.js +173 -0
  65. package/src/hooks/useStoreContacts/index.js +5 -1
  66. package/src/hooks/useUpdateExistingOrders/index.js +8 -8
  67. package/src/hooks/useUser/index.js +7 -2
  68. package/src/hooks/useUser/queries.js +40 -0
  69. package/src/index.jsx +3 -1
  70. package/.vscode/extensions.json +0 -6
  71. package/.vscode/settings.json +0 -8
  72. package/src/hooks/useSchedule/index.jsx +0 -23
@@ -0,0 +1,102 @@
1
+ export const getDayFromOpeningKey = (key) => {
2
+ const days = {
3
+ openingSun: 0,
4
+ openingMon: 1,
5
+ openingTue: 2,
6
+ openingWed: 3,
7
+ openingThu: 4,
8
+ openingFri: 5,
9
+ openingSat: 6
10
+ };
11
+ return days[key] !== undefined ? days[key] : -1
12
+ }
13
+
14
+ // Función para convertir el objeto de tiempo en una cadena de tiempo
15
+ export function getTimeString(timeStr) {
16
+ return timeStr || '00:00'; // Return '00:00' for empty time strings
17
+ }
18
+
19
+
20
+ export function getCurrentDayAndTime() {
21
+ try {
22
+ const date = new Date();
23
+ const currentTime = date.getHours() * 60 + date.getMinutes();
24
+ const currentDayOfWeek = date.getDay();
25
+ return { currentTime, currentDayOfWeek };
26
+ } catch (error) {
27
+ return {
28
+
29
+ }
30
+ }
31
+ }
32
+
33
+ export function getTimeObject(timeStr) {
34
+ try {
35
+ if (!timeStr || !/\d{2}:\d{2}/.test(timeStr)) {
36
+ return { hours: 0, minutes: 0 }; // Return default values for invalid input
37
+ }
38
+ const [hours, minutes] = timeStr.split(':').map(str => parseInt(str));
39
+ return { hours, minutes };
40
+ } catch (e) {
41
+ return { hours: 0, minutes: 0 }; // Return default values on error
42
+ }
43
+ }
44
+
45
+ export function sortOpeningsByDay(openings) {
46
+ const days = [
47
+ 'openingSun',
48
+ 'openingMon',
49
+ 'openingTue',
50
+ 'openingWed',
51
+ 'openingThu',
52
+ 'openingFri',
53
+ 'openingSat'
54
+ ]
55
+ const sortedOpenings = {};
56
+
57
+ days.forEach((day) => {
58
+ sortedOpenings[day] = openings[day] || '00:00 - 00:00'; // Agregar horario vacío para los días faltantes
59
+ });
60
+
61
+ return sortedOpenings;
62
+ }
63
+
64
+ // Función para obtener la clave de openings a partir del día de la semana
65
+ export function getOpeningKeyFromDay(day) {
66
+ const days = {
67
+ 0: 'openingSun',
68
+ 1: 'openingMon',
69
+ 2: 'openingTue',
70
+ 3: 'openingWed',
71
+ 4: 'openingThu',
72
+ 5: 'openingFri',
73
+ 6: 'openingSat'
74
+ };
75
+ return days[day];
76
+ }
77
+
78
+ export const weekDays = [
79
+ 'Domingo',
80
+ 'Lunes',
81
+ 'Martes',
82
+ 'Miércoles',
83
+ 'Jueves',
84
+ 'Viernes',
85
+ 'Sábado'
86
+ ]
87
+
88
+ export function timeToInt(text) {
89
+ let hour = parseInt(text.substring(0, 2));
90
+ let minute = parseInt(text.substring(3));
91
+ return hour * 60 + minute;
92
+ }
93
+
94
+ export const days = {
95
+ Monday: 'Lunes',
96
+ Tuesday: 'Martes',
97
+ Wednesday: 'Miércoles',
98
+ Thursday: 'Jueves',
99
+ Friday: 'Viernes',
100
+ Saturday: 'Sábado',
101
+ Sunday: 'Domingo'
102
+ };
@@ -0,0 +1,173 @@
1
+ import { useEffect, useState } from 'react'
2
+ import {
3
+ getDayFromOpeningKey,
4
+ getCurrentDayAndTime,
5
+ getOpeningKeyFromDay,
6
+ getTimeString,
7
+ sortOpeningsByDay,
8
+ weekDays,
9
+ timeToInt,
10
+ days,
11
+ getTimeObject
12
+ } from './helpers';
13
+ import { useFormatDate } from '../useFormatDate';
14
+
15
+ export const useStatusOpenStore = ({ dataSchedules = [] } = {}) => {
16
+ const [open, setOpen] = useState('')
17
+ const [openNow, setOpenNow] = useState(false)
18
+ const { handleHourPmAM } = useFormatDate({})
19
+
20
+ const handleMessageHour = (message, open) => {
21
+ setOpen(message)
22
+ setOpenNow(open)
23
+ }
24
+
25
+ function getNextDaySchedule(dataSchedules, currentDayOfWeek) {
26
+ const today = new Date();
27
+ const tomorrow = new Date(today);
28
+ tomorrow.setDate(today.getDate() + 1);
29
+ const dayOfWeekTomorrow = tomorrow.getDay();
30
+
31
+ const findNextDay = dataSchedules?.length
32
+ ? dataSchedules?.some((schedule) => schedule?.schDay === dayOfWeekTomorrow)
33
+ : false;
34
+
35
+ const findDataNextDay = dataSchedules?.length
36
+ ? dataSchedules?.find((schedule) => schedule?.schDay === dayOfWeekTomorrow)
37
+ : {};
38
+
39
+ return { findNextDay, findDataNextDay, dayOfWeekTomorrow };
40
+ }
41
+
42
+ function getOpeningStatus(openings, currentTime, currentDayOfWeek) {
43
+ const weekDayLookup = [
44
+ 'Sunday',
45
+ 'Monday',
46
+ 'Tuesday',
47
+ 'Wednesday',
48
+ 'Thursday',
49
+ 'Friday',
50
+ 'Saturday',
51
+ ];
52
+
53
+ const ceroHours = '00:00 - 00:00';
54
+ let dayOfWeek = currentDayOfWeek;
55
+
56
+ for (let i = 0; i < 7; i++) {
57
+ const dayName = weekDayLookup[dayOfWeek % 7];
58
+ const opening = openings && openings['opening' + dayName.substring(0, 3)];
59
+ const timeSpans = opening?.split(';').map((item) => item.trim());
60
+
61
+ for (let span of timeSpans) {
62
+ const hours = span.split('-').map((item) => item.trim());
63
+ const openTime = timeToInt(hours[0]);
64
+ const closeTime = timeToInt(hours[1]);
65
+
66
+ if (currentTime >= openTime && currentTime <= closeTime) {
67
+ return handleMessageHour(
68
+ 'Abierto Ahora - Cierra a las: ' + handleHourPmAM(hours[1]),
69
+ true
70
+ );
71
+ }
72
+
73
+ if (currentTime < openTime && dayOfWeek === currentDayOfWeek) {
74
+ return handleMessageHour(
75
+ 'Aun temprano - Abre hoy a las: ' + handleHourPmAM(hours[0]),
76
+ false
77
+ );
78
+ }
79
+
80
+ if (currentTime >= closeTime - 30 * 60000 && currentTime < closeTime && dayOfWeek === currentDayOfWeek) {
81
+ return handleMessageHour(
82
+ 'Pronto por cerrar - Cierra hoy a las: ' + handleHourPmAM(hours[1]),
83
+ true
84
+ );
85
+ }
86
+
87
+ const { findNextDay, findDataNextDay, dayOfWeekTomorrow } = getNextDaySchedule(
88
+ dataSchedules,
89
+ currentDayOfWeek
90
+ );
91
+
92
+ if (findNextDay && findDataNextDay?.schHoSta) {
93
+ const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow];
94
+ return handleMessageHour(
95
+ `Cerrado - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
96
+ !!findDataNextDay?.schHoSta ? findDataNextDay?.schHoSta : ''
97
+ }`,
98
+ false
99
+ );
100
+ }
101
+
102
+ const nextDayName = weekDayLookup[(dayOfWeek + 1) % 7];
103
+ const nextOpening = openings && openings['opening' + nextDayName.substring(0, 3)];
104
+ const nextHours = nextOpening?.split(';')?.map((item) => item?.trim());
105
+
106
+ if (nextHours[0] !== ceroHours) {
107
+ return handleMessageHour(
108
+ 'Cerrado - Abre el ' + days[nextDayName] + ' a las ' + nextHours[0],
109
+ false
110
+ );
111
+ }
112
+ }
113
+
114
+ dayOfWeek++;
115
+ }
116
+
117
+ return handleMessageHour('Cerrado', false);
118
+ }
119
+
120
+ function getIsOpening(openings) {
121
+ const { currentTime, currentDayOfWeek } = getCurrentDayAndTime();
122
+ return getOpeningStatus(openings, currentTime, currentDayOfWeek);
123
+ }
124
+
125
+
126
+ useEffect(() => {
127
+ (() => {
128
+ // Crear el objeto openings a partir del existStoreSchedule
129
+ const openings = {};
130
+ const existStoreSchedule = dataSchedules || []
131
+ existStoreSchedule?.forEach((schedule) => {
132
+ const day = schedule.schDay;
133
+ const openingKey = getOpeningKeyFromDay(day);
134
+ const schHoSta = getTimeString(schedule?.schHoSta);
135
+ const schHoEnd = getTimeString(schedule?.schHoEnd);
136
+ openings[openingKey] = `${schHoSta} - ${schHoEnd}`;
137
+ });
138
+
139
+ for (let i = 0; i < 7; i++) {
140
+ const openingKey = getOpeningKeyFromDay(i);
141
+ if (!openings.hasOwnProperty(openingKey)) {
142
+ openings[openingKey] = '00:00 - 00:00'; // Horario vacío para el día faltante
143
+ }
144
+ }
145
+
146
+
147
+ // Ejemplo de uso con el objeto proporcionado
148
+ const sortedOpenings = sortOpeningsByDay(openings);
149
+
150
+
151
+ // Crear el array completo con objetos de tiempo
152
+ const fullArray = Object.keys(sortedOpenings).map((key) => {
153
+ const day = getDayFromOpeningKey(key);
154
+ const [schHoSta, schHoEnd] = openings[key].split(' - ').map(timeStr => getTimeObject(timeStr));
155
+ return {
156
+ "__typename": "StoreSchedule",
157
+ "schId": "",
158
+ "idStore": "",
159
+ "schDay": day,
160
+ "schHoSta": `${schHoSta?.hours?.toString().padStart(2, '0')}:${schHoSta?.minutes?.toString().padStart(2, '0')}`,
161
+ "schHoEnd": `${schHoEnd?.hours?.toString().padStart(2, '0')}:${schHoEnd?.minutes?.toString().padStart(2, '0')}`,
162
+ "schState": 1
163
+ };
164
+ })
165
+ getIsOpening(sortedOpenings)
166
+ })()
167
+ }, [dataSchedules])
168
+
169
+ return {
170
+ open,
171
+ openNow
172
+ }
173
+ }
@@ -36,7 +36,11 @@ export const useGetOneUseStoreContacts = ({ sendNotification = () => { return }
36
36
  }
37
37
 
38
38
  export const useEditOneUseStoreContacts = ({ sendNotification = () => { return } } = {}) => {
39
- const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT)
39
+ const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT, {
40
+ onError: e => {
41
+ console.error(e)
42
+ }
43
+ })
40
44
  return [editOneContacts, { data: data?.editOneContacts, loading, error }]
41
45
  }
42
46
 
@@ -1,5 +1,5 @@
1
1
  export const isValidCodeRef = (codeRef) => {
2
- return typeof codeRef === "string" && codeRef.trim() !== "";
2
+ return typeof codeRef === 'string' && codeRef.trim() !== '';
3
3
  };
4
4
 
5
5
  export const isValidState = (state) => {
@@ -13,11 +13,11 @@ export const updateExistingOrders = (
13
13
  pSState,
14
14
  objectToAdd
15
15
  ) => {
16
- if (typeof existingOrders !== "object" || existingOrders === null) {
16
+ if (typeof existingOrders !== 'object' || existingOrders === null) {
17
17
  // existingOrders no es un objeto válido
18
18
  return existingOrders;
19
19
  }
20
- if (typeof pCodeRef !== "string" || typeof pSState !== "number") {
20
+ if (typeof pCodeRef !== 'string' || typeof pSState !== 'number') {
21
21
  // Los tipos de datos de pCodeRef y pSState no son los esperados
22
22
  return existingOrders;
23
23
  }
@@ -29,11 +29,11 @@ export const updateExistingOrders = (
29
29
  const updatedExistingOrders = { ...existingOrders }; // Copiar el objeto existente
30
30
 
31
31
  const statusKeys = {
32
- 1: "ACEPTA",
33
- 2: "PROCESSING",
34
- 3: "READY",
35
- 4: "CONCLUDES",
36
- 5: "RECHAZADOS",
32
+ 1: 'ACEPTA',
33
+ 2: 'PROCESSING',
34
+ 3: 'READY',
35
+ 4: 'CONCLUDES',
36
+ 5: 'RECHAZADOS',
37
37
  };
38
38
  const targetArray = statusKeys[pSState];
39
39
 
@@ -1,11 +1,16 @@
1
- import { useQuery } from '@apollo/client'
2
- import { GET_USER, SET_USER_PROFILE } from './queries'
1
+ import { useQuery, useMutation } from '@apollo/client'
2
+ import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
3
3
 
4
4
  export const useUser = () => {
5
5
  const { data, loading, error } = useQuery(GET_USER)
6
6
  return [data?.getUser, { loading, error }]
7
7
  }
8
8
 
9
+ export const useUserProfile = () => {
10
+ const { data, loading, error } = useQuery(GET_USER_PROFILE)
11
+ return [data?.getOneUserProfile, { loading, error }]
12
+ }
13
+
9
14
  export const useSetUserProfile = () => {
10
15
  const [setUserProfile, { loading, error }] = useMutation(SET_USER_PROFILE)
11
16
  return [setUserProfile, { loading, error }]
@@ -84,4 +84,44 @@ export const SET_USER_PROFILE = gql`
84
84
  upZipCode
85
85
  }
86
86
  }
87
+ `
88
+
89
+ export const GET_USER_PROFILE = gql`
90
+ query getOneUserProfile($id: ID) {
91
+ getOneUserProfile(id: $id){
92
+ upId
93
+ id
94
+ upPhone
95
+ upImage
96
+ upDateBir
97
+ upBloodG
98
+ upAddress
99
+ ctId
100
+ dId
101
+ upZipCode
102
+ cId
103
+ upLatitude
104
+ upLongitude
105
+ user {
106
+ id
107
+ name
108
+ username
109
+ lastName
110
+ email
111
+ avatar
112
+ uToken
113
+ uPhoNum
114
+ ULocation
115
+ upLat
116
+ uState
117
+ upLon
118
+ upIdeDoc
119
+ siteWeb
120
+ description
121
+ password
122
+ createAt
123
+
124
+ }
125
+ }
126
+ }
87
127
  `
package/src/index.jsx CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './hooks/index'
2
- export * from './utils'
2
+ export * from './utils'
3
+ export * from './config/client'
4
+ export * from './mock'
@@ -1,6 +0,0 @@
1
- {
2
- "recommendations": [
3
- "github.copilot",
4
- "github.copilot-nightly"
5
- ]
6
- }
@@ -1,8 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "Anauthorized",
4
- "deepmerge",
5
- "Eliminado",
6
- "Pedido"
7
- ]
8
- }
@@ -1,23 +0,0 @@
1
- import { useQuery } from '@apollo/client'
2
- import { GET_ONE_SCHEDULE_STORE, GET_SCHEDULE_STORE } from '../useProductsFood/queriesStore'
3
-
4
- export const useSchedule = ({ day = null }) => {
5
- const {
6
- data,
7
- loading,
8
- error
9
- } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day } })
10
-
11
- return [data?.getOneStoreSchedules, { loading, error }]
12
- }
13
-
14
- export const useSchedules = ({ schDay = 1 }) => {
15
- const {
16
- data,
17
- loading,
18
- error
19
- } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay } })
20
-
21
-
22
- return [data?.getStoreSchedules, { loading, error }]
23
- }