npm-pkg-hook 1.0.9 → 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 (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 -6
  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 +96 -66
  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/index.js +19 -4
  39. package/src/hooks/useProductsFood/queriesStore.js +3 -16
  40. package/src/hooks/useProductsFood/useEditProduct.js +10 -0
  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/useStore/index.js +30 -16
  66. package/src/hooks/useUpdateExistingOrders/index.js +91 -0
  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,25 @@
1
+ import { useQuery } from '@apollo/client';
2
+ import { GET_ALL_SALES_STATISTICS } from '../queries';
3
+
4
+ export const useGetAllSales = ({
5
+ fromDate = '',
6
+ toDate = ''
7
+ } = {}) => {
8
+ const {
9
+ data,
10
+ loading,
11
+ error
12
+ } = useQuery(GET_ALL_SALES_STATISTICS, {
13
+ fetchPolicy: 'cache-first',
14
+ variables: {
15
+ fromDate,
16
+ toDate,
17
+ },
18
+ });
19
+
20
+ return {
21
+ data: data?.getAllSalesStoreStatistic || [],
22
+ error,
23
+ loading
24
+ };
25
+ };
@@ -1,8 +1,22 @@
1
1
  import { useLazyQuery } from '@apollo/client'
2
2
  import { GET_ONE_SALE } from './queries'
3
3
 
4
- export const useGetSale = () => {
5
- const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
4
+ export const useGetSale = ({ callback = () => { return } } = {}) => {
5
+ const [getOnePedidoStore, {
6
+ loading,
7
+ data,
8
+ called,
9
+ error
10
+ }] = useLazyQuery(GET_ONE_SALE, {
11
+ onCompleted: (res) => {
12
+ if (res?.getOnePedidoStore) {
13
+ return callback(res)
14
+ }
15
+ },
16
+ onError: () => {
17
+ return callback(null)
18
+ }
19
+ })
6
20
  return {
7
21
  data: data?.getOnePedidoStore, // actualizado aquí
8
22
  loading,
@@ -0,0 +1,36 @@
1
+ import { useQuery, useMutation } from '@apollo/client'
2
+ import { GET_ONE_SCHEDULE_STORE, GET_SCHEDULE_STORE, CREATE_STORE_CALENDAR } from './queries'
3
+ export { GET_ONE_SCHEDULE_STORE, GET_SCHEDULE_STORE, CREATE_STORE_CALENDAR } from './queries'
4
+
5
+ export const useSchedule = ({ day = null }) => {
6
+ const {
7
+ data,
8
+ loading,
9
+ error
10
+ } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day } })
11
+
12
+ return [data?.getOneStoreSchedules, { loading, error }]
13
+ }
14
+
15
+ export const useSchedules = ({ schDay = 1 }) => {
16
+ const {
17
+ data,
18
+ loading,
19
+ error
20
+ } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay } })
21
+
22
+
23
+ return [data?.getStoreSchedules, { loading, error }]
24
+ }
25
+
26
+ export const useCreateSchedules = () => {
27
+ const [setStoreSchedule, { loading, error }] = useMutation(CREATE_STORE_CALENDAR, {
28
+ onError: (e) => {
29
+ console.error(e)
30
+ }
31
+ })
32
+
33
+
34
+
35
+ return [setStoreSchedule, { loading, error }]
36
+ }
@@ -0,0 +1,35 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const CREATE_STORE_CALENDAR = gql`
4
+ mutation setStoreSchedule($input: ITstoreSchedule!){
5
+ setStoreSchedule(input: $input){
6
+ message
7
+ success
8
+ }
9
+ }
10
+ `
11
+ export const GET_SCHEDULE_STORE = gql`
12
+ query getStoreSchedules($schDay: Int, $idStore: ID) {
13
+ getStoreSchedules(schDay: $schDay, idStore: $idStore) {
14
+ schId
15
+ idStore
16
+ schDay
17
+ schHoSta
18
+ schHoEnd
19
+ schState
20
+ }
21
+ }
22
+ `;
23
+
24
+ export const GET_ONE_SCHEDULE_STORE = gql`
25
+ query getOneStoreSchedules($schDay: Int, $idStore: ID) {
26
+ getOneStoreSchedules(schDay: $schDay, idStore: $idStore) {
27
+ schId
28
+ schDay
29
+ schHoSta
30
+ schHoEnd
31
+ schState
32
+ }
33
+ }
34
+ `;
35
+
@@ -0,0 +1,171 @@
1
+ export function useScheduleData(data) {
2
+
3
+ const days = {
4
+ 1: 'Lunes',
5
+ 2: 'Martes',
6
+ 3: 'Miércoles',
7
+ 4: 'Jueves',
8
+ 5: 'Viernes',
9
+ 6: 'Sabado',
10
+ 0: 'Domingo'
11
+ }
12
+
13
+ const daysArray = [
14
+ { day: 0, schHoSta: "", schHoEnd: "" },
15
+ { day: 1, schHoSta: "", schHoEnd: "" },
16
+ { day: 2, schHoSta: "", schHoEnd: "" },
17
+ { day: 3, schHoSta: "", schHoEnd: "" },
18
+ { day: 4, schHoSta: "", schHoEnd: "" },
19
+ { day: 5, schHoSta: "", schHoEnd: "" },
20
+ { day: 6, schHoSta: "", schHoEnd: "" }
21
+ ];
22
+
23
+ const combinedArray = daysArray.map((dayObj) => {
24
+ const originalObj = data?.find((item) => item.schDay === dayObj.day);
25
+ return originalObj ? originalObj : { ...dayObj };
26
+ });
27
+
28
+ // Encontrar la hora de inicio más temprana en combinedArray
29
+ const earliestStartTime = Math.min(
30
+ ...combinedArray.map((item) => {
31
+ const time = new Date(`2023-08-01 ${item.schHoSta}`);
32
+ return time.getTime();
33
+ })
34
+ );
35
+
36
+ const calculateYPosition = (start) => {
37
+ const time = new Date(`2023-08-01 ${start}`);
38
+ const differenceInMinutes = (time.getTime() - earliestStartTime) / (1000 * 40);
39
+ return differenceInMinutes / 40; // Ajusta el valor para adaptarse a la posición deseada en el eje Y
40
+ }
41
+
42
+ /**
43
+ * Calcula la duración en horas entre dos horas de inicio y final.
44
+ * @param {string} startTime - Hora de inicio en formato 'HH:mm'.
45
+ * @param {string} endTime - Hora de fin en formato 'HH:mm'.
46
+ * @returns {number} Duración en horas con dos decimales.
47
+ */
48
+
49
+ // Función para calcular la duración en horas de un horario
50
+ function calculateDurationInHours(startTime, endTime) {
51
+ const startHour = new Date(`2000-01-01T${startTime}`);
52
+ const endHour = new Date(`2000-01-01T${endTime}`);
53
+ const duration = (endHour - startHour) / (1000 * 40 * 40); // Convertir la diferencia en horas
54
+ return duration.toFixed(2); // Redondear a 2 decimales
55
+ }
56
+
57
+ // Variables para controlar la posición en el eje X
58
+ let columnIndex = 0;
59
+ let lastDay = -1;
60
+ const uniqueHoursSet = new Set([
61
+ ...combinedArray.map((item) => item.schHoSta),
62
+ ...combinedArray.map((item) => item.schHoEnd),
63
+ ]);
64
+
65
+
66
+ const uniqueHours = [];
67
+ for (const hour of uniqueHoursSet) {
68
+ const time = new Date(`2023-08-01 ${hour}`);
69
+ const formattedHour = time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
70
+ uniqueHours.push(formattedHour);
71
+ }
72
+
73
+ uniqueHours.sort((a, b) => {
74
+ const timeA = new Date(`2023-08-01 ${a}`);
75
+ const timeB = new Date(`2023-08-01 ${b}`);
76
+ return timeA - timeB;
77
+ });
78
+
79
+ // Agregar las horas que faltan al final del día
80
+ if (uniqueHours.length > 0) {
81
+ const lastHour = new Date(`2023-08-01 ${uniqueHours[uniqueHours.length - 1]}`);
82
+ const endTime = new Date(`2023-08-01 ${combinedArray[0].schHoEnd}`);
83
+ const hoursDifference = (endTime - lastHour) / (1000 * 60 * 60);
84
+
85
+ for (let i = 1; i <= hoursDifference; i++) {
86
+ const newHour = new Date(lastHour.getTime() + i * 60 * 60 * 1000);
87
+ const formattedNewHour = newHour.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
88
+ uniqueHours.push(formattedNewHour);
89
+ }
90
+ }
91
+
92
+ const dayWidth = 100;
93
+ const daysWithHours = Array.from(new Set(combinedArray.map((item) => (item.schDay !== undefined ? item.schDay : item.day))));
94
+ const totalDays = daysWithHours.length;
95
+ const totalWidth = totalDays * dayWidth;
96
+ const MINUTES_THRESHOLDS = [1, 2, 3, 4, 5, 15, 30]; // Define los umbrales de minutos para agrupar
97
+
98
+ const sortedUniqueHours = Array.from(uniqueHoursSet)
99
+ .sort((a, b) => {
100
+ const timeA = new Date(`2023-08-01 ${a}`);
101
+ const timeB = new Date(`2023-08-01 ${b}`);
102
+ return timeA - timeB;
103
+ });
104
+
105
+ const groupedHours = [];
106
+ let currentGroup = [sortedUniqueHours[0]];
107
+
108
+ for (let i = 1; i < sortedUniqueHours.length; i++) {
109
+ const prevTime = new Date(`2023-08-01 ${sortedUniqueHours[i - 1]}`);
110
+ const currentTime = new Date(`2023-08-01 ${sortedUniqueHours[i]}`);
111
+ const timeDifference = (currentTime - prevTime) / (1000 * 60);
112
+
113
+ let shouldGroup = false;
114
+
115
+ for (const threshold of MINUTES_THRESHOLDS) {
116
+ if (timeDifference <= threshold) {
117
+ shouldGroup = true;
118
+ break;
119
+ }
120
+ }
121
+
122
+ if (shouldGroup) {
123
+ currentGroup.push(sortedUniqueHours[i]);
124
+ } else {
125
+ if (currentGroup.length > 2) {
126
+ groupedHours.push(currentGroup.join(' - '));
127
+ } else {
128
+ groupedHours.push(...currentGroup);
129
+ }
130
+ currentGroup = [sortedUniqueHours[i]];
131
+ }
132
+ }
133
+
134
+ if (currentGroup.length > 2) {
135
+ groupedHours.push(currentGroup.join(' - '));
136
+ } else {
137
+ groupedHours.push(...currentGroup);
138
+ }
139
+
140
+ const combinedHours = groupedHours.reduce((acc, group) => {
141
+ if (group.includes('-')) {
142
+ acc.push(group);
143
+ } else {
144
+ acc.push(...group.split(' - '));
145
+ }
146
+ return acc;
147
+ }, []);
148
+
149
+ const formattedHours = combinedHours;
150
+
151
+
152
+ function calculateTimeLinesHeight() {
153
+ const totalHours = uniqueHours.length;
154
+ return totalHours * 60; // Cada hora ocupa 60 píxeles de altura
155
+ }
156
+ return {
157
+ columnIndex,
158
+ combinedArray: combinedArray,
159
+ days,
160
+ daysArray,
161
+ daysWithHours,
162
+ dayWidth,
163
+ lastDay,
164
+ totalWidth,
165
+ sortedUniqueHours,
166
+ uniqueHours: formattedHours,
167
+ calculateDurationInHours,
168
+ calculateTimeLinesHeight,
169
+ calculateYPosition
170
+ };
171
+ }
@@ -0,0 +1,57 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ export const useScrollY = () => {
4
+ // Función scroll Para mover verticalmente
5
+ const [offsetY, setOffsetY] = useState(0)
6
+ const handleScroll = () => {return setOffsetY(window.pageYOffset)}
7
+
8
+ useEffect(() => {
9
+ window.addEventListener('scroll', handleScroll)
10
+ return () => {return window.removeEventListener('scroll', handleScroll)}
11
+ }, [])
12
+ return {
13
+ offsetY
14
+ }
15
+ }
16
+
17
+
18
+ export const useScrollColor = () => {
19
+ const [scrollNav, setScrollNav] = useState(false)
20
+ const changeNav = () => {
21
+ if (window?.scrollY >= 1) {
22
+ setScrollNav(true)
23
+ } else {
24
+ setScrollNav(false)
25
+ }
26
+ }
27
+ useEffect(() => {
28
+ window.addEventListener('scroll', changeNav)
29
+ }, [])
30
+ return {
31
+ scrollNav
32
+ }
33
+ }
34
+
35
+ export const useScrollHook = () => {
36
+ const [style, setStyle] = useState({})
37
+
38
+ useEffect(() => {
39
+ let scrollPos = 0
40
+ const handleChangeHeaderStyle = () => {
41
+ if ( document.body?.getBoundingClientRect && document.body.getBoundingClientRect().top > scrollPos) {
42
+ setStyle({})
43
+ } else {
44
+ setStyle({ transform: 'translateY(-300%)' })
45
+ }
46
+ scrollPos = document.body.getBoundingClientRect().top
47
+ }
48
+
49
+ window.addEventListener('scroll', handleChangeHeaderStyle)
50
+
51
+ return () => {
52
+ window.removeEventListener('scroll', handleChangeHeaderStyle)
53
+ }
54
+ }, [])
55
+
56
+ return style
57
+ }
@@ -0,0 +1,14 @@
1
+ // Función scroll Para rotar
2
+ export const useScrollRotate = () => {
3
+ const [position, setPosition] = useState(0)
4
+
5
+ useEffect(() => {
6
+ const handleScroll = () => {return setPosition(window.scrollY)}
7
+ window.addEventListener('scroll', handleScroll)
8
+ return () => {
9
+ window.removeEventListener('scroll', handleScroll)
10
+ }
11
+ }, [])
12
+
13
+ return { position }
14
+ }
@@ -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
+ }