npm-pkg-hook 1.3.6 → 1.3.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 (97) hide show
  1. package/.eslintrc.js +38 -38
  2. package/.eslintrc.json +127 -127
  3. package/.github/pull_request_template.md +17 -17
  4. package/.github/workflows/pepeline.yaml +29 -29
  5. package/package.json +46 -46
  6. package/script.txt +6 -6
  7. package/src/config/client/index.js +1 -1
  8. package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -7
  9. package/src/hooks/getCategoriesWithProduct/index.js +62 -62
  10. package/src/hooks/getSession/index.js +18 -18
  11. package/src/hooks/handleLogin/index.js +10 -0
  12. package/src/hooks/index.js +1 -0
  13. package/src/hooks/useAnimationFrame/index.js +45 -45
  14. package/src/hooks/useAsideCart/index.js +155 -155
  15. package/src/hooks/useAsideCart/queries.js +10 -10
  16. package/src/hooks/useCart/index.js +2 -2
  17. package/src/hooks/useCart/queries.js +164 -164
  18. package/src/hooks/useCart/useCart/helpers/index.js +75 -75
  19. package/src/hooks/useCart/useCart/index.js +410 -410
  20. package/src/hooks/useCart/useGetCart/index.js +31 -31
  21. package/src/hooks/useCatWithProductClient/index.js +56 -56
  22. package/src/hooks/useCatWithProductClient/queries.js +55 -55
  23. package/src/hooks/useCategoriesProduct/index.js +12 -12
  24. package/src/hooks/useCategoriesProduct/queries.js +16 -16
  25. package/src/hooks/useCategoryInStore/queries.js +78 -78
  26. package/src/hooks/useChartData/useChartData/index.js +199 -199
  27. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
  28. package/src/hooks/useCheckbox/index.js +115 -115
  29. package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +52 -0
  30. package/src/hooks/useCreateProduct/index.js +8 -3
  31. package/src/hooks/useDeleteSubProductOptional/index.js +30 -30
  32. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
  33. package/src/hooks/useDessert/helpers/index.js +51 -51
  34. package/src/hooks/useDevices/index.js +35 -35
  35. package/src/hooks/useDevices/queries.js +19 -19
  36. package/src/hooks/useDropzone/index.js +94 -94
  37. package/src/hooks/useDynamicAuth/index.js +13 -13
  38. package/src/hooks/useDynamicAuth/queries.js +24 -24
  39. package/src/hooks/useEditSubProductOptional/queries.js +10 -10
  40. package/src/hooks/useEvent/index.js +33 -33
  41. package/src/hooks/useFavoriteStores/index.js +19 -19
  42. package/src/hooks/useFavoriteStores/queries.js +47 -47
  43. package/src/hooks/useFetchJson/index.js +25 -25
  44. package/src/hooks/useFingerprintjs/index.js +172 -172
  45. package/src/hooks/useFullScreenMode/index.js +65 -65
  46. package/src/hooks/useGenerateNumberArray/index.js +17 -17
  47. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -14
  48. package/src/hooks/useGetFoodRecomended/index.js +32 -33
  49. package/src/hooks/useGetFoodRecomended/queries.js +47 -47
  50. package/src/hooks/useGetMinPrice/index.js +12 -12
  51. package/src/hooks/useGetMinPrice/queries.js +7 -7
  52. package/src/hooks/useGetOneStoreRating/index.js +40 -40
  53. package/src/hooks/useGetOneStoreRating/queries.js +18 -18
  54. package/src/hooks/useGoogleLogin/index.js +160 -160
  55. package/src/hooks/useGoogleLogin/loadScript.js +15 -15
  56. package/src/hooks/useGoogleLogin/removeScript.js +7 -7
  57. package/src/hooks/useHover/index.js +29 -29
  58. package/src/hooks/useImagesStore/index.js +5 -4
  59. package/src/hooks/useInnerHtml/index.js +39 -39
  60. package/src/hooks/useKeypress/index.js +28 -28
  61. package/src/hooks/useLocationNavigate/index.js +54 -54
  62. package/src/hooks/useLogout/index.js +29 -21
  63. package/src/hooks/useManageQueryParams/index.js +37 -36
  64. package/src/hooks/useMobile/index.js +39 -39
  65. package/src/hooks/useOrderClient/index.js +5 -5
  66. package/src/hooks/useProviders/index.js +3 -3
  67. package/src/hooks/useProviders/queries.js +31 -31
  68. package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -12
  69. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
  70. package/src/hooks/useProvidersStore/index.js +24 -24
  71. package/src/hooks/useProvidersStore/queries.js +31 -31
  72. package/src/hooks/useRatingArrayData/index.js +54 -54
  73. package/src/hooks/useRatingArrayData/queries.js +19 -19
  74. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
  75. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
  76. package/src/hooks/useRestaurant/index.js +19 -19
  77. package/src/hooks/useRestaurant/queries.js +80 -80
  78. package/src/hooks/useSales/useGetAllSales/index.js +25 -25
  79. package/src/hooks/useSchedule/index.js +72 -72
  80. package/src/hooks/useSchedule/index.jsx +22 -22
  81. package/src/hooks/useSchedule/queries.js +43 -43
  82. package/src/hooks/useScheduleData/index.js +123 -123
  83. package/src/hooks/useScroll/index.js +56 -56
  84. package/src/hooks/useScrollRotate/index.js +16 -16
  85. package/src/hooks/useStatusOpenStore/helpers/index.js +101 -101
  86. package/src/hooks/useStatusOpenStore/index.js +172 -172
  87. package/src/hooks/useStatusOrdersClient/queries.js +80 -80
  88. package/src/hooks/useStore/queries.js +163 -163
  89. package/src/hooks/useStoreCalendar/index.js +5 -5
  90. package/src/hooks/useStoreContacts/queries.js +1 -1
  91. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  92. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -38
  93. package/src/hooks/useWindowSize/index.js +38 -38
  94. package/src/mock/dessert/index.js +16 -16
  95. package/src/mock/index.js +1 -1
  96. package/.vscode/extensions.json +0 -6
  97. package/.vscode/settings.json +0 -8
@@ -1,72 +1,72 @@
1
- import { useQuery, useMutation } from '@apollo/client'
2
- import {
3
- GET_ONE_SCHEDULE_STORE,
4
- GET_SCHEDULE_STORE,
5
- CREATE_STORE_CALENDAR,
6
- SET_STATUS_ALL_SCHEDULE_STORE
7
- } from './queries'
8
-
9
- export const useSchedule = ({ day = null, idStore = '' }) => {
10
- const {
11
- data,
12
- loading,
13
- error
14
- } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day, idStore } })
15
-
16
- return [data?.getOneStoreSchedules, { loading, error }]
17
- }
18
-
19
- export const useSetScheduleOpenAll = () => {
20
- const [setStoreSchedule, { loading, error }] = useMutation(SET_STATUS_ALL_SCHEDULE_STORE, {
21
- onError: (e) => {
22
- console.error(e);
23
- }
24
- });
25
-
26
- const handleSetStoreSchedule = (scheduleOpenAll) => {
27
- setStoreSchedule({
28
- variables: {
29
- scheduleOpenAll: scheduleOpenAll
30
- }, update: (cache, { data }) => {
31
- const success = data?.setScheduleOpenAll?.success
32
- if (success) {
33
- cache.modify({
34
- fields: {
35
- getStore (_, { readField }) {
36
- const store = readField('getStore')
37
- const updatedCart = {
38
- ...store,
39
- scheduleOpenAll: scheduleOpenAll
40
- }
41
- return updatedCart
42
- }
43
- }
44
- })
45
- }
46
- }
47
- });
48
- };
49
-
50
- return [handleSetStoreSchedule, { loading, error }];
51
- };
52
-
53
-
54
- export const useSchedules = ({ schDay = 1, idStore = '' }) => {
55
- const {
56
- data,
57
- loading,
58
- error
59
- } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay, idStore } })
60
-
61
- return [data?.getStoreSchedules, { loading, error }]
62
- }
63
-
64
- export const useCreateSchedules = () => {
65
- const [setStoreSchedule, { loading, error }] = useMutation(CREATE_STORE_CALENDAR, {
66
- onError: (e) => {
67
- console.error(e)
68
- }
69
- })
70
-
71
- return [setStoreSchedule, { loading, error }]
72
- }
1
+ import { useQuery, useMutation } from '@apollo/client'
2
+ import {
3
+ GET_ONE_SCHEDULE_STORE,
4
+ GET_SCHEDULE_STORE,
5
+ CREATE_STORE_CALENDAR,
6
+ SET_STATUS_ALL_SCHEDULE_STORE
7
+ } from './queries'
8
+
9
+ export const useSchedule = ({ day = null, idStore = '' }) => {
10
+ const {
11
+ data,
12
+ loading,
13
+ error
14
+ } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day, idStore } })
15
+
16
+ return [data?.getOneStoreSchedules, { loading, error }]
17
+ }
18
+
19
+ export const useSetScheduleOpenAll = () => {
20
+ const [setStoreSchedule, { loading, error }] = useMutation(SET_STATUS_ALL_SCHEDULE_STORE, {
21
+ onError: (e) => {
22
+ console.error(e);
23
+ }
24
+ });
25
+
26
+ const handleSetStoreSchedule = (scheduleOpenAll) => {
27
+ setStoreSchedule({
28
+ variables: {
29
+ scheduleOpenAll: scheduleOpenAll
30
+ }, update: (cache, { data }) => {
31
+ const success = data?.setScheduleOpenAll?.success
32
+ if (success) {
33
+ cache.modify({
34
+ fields: {
35
+ getStore (_, { readField }) {
36
+ const store = readField('getStore')
37
+ const updatedCart = {
38
+ ...store,
39
+ scheduleOpenAll: scheduleOpenAll
40
+ }
41
+ return updatedCart
42
+ }
43
+ }
44
+ })
45
+ }
46
+ }
47
+ });
48
+ };
49
+
50
+ return [handleSetStoreSchedule, { loading, error }];
51
+ };
52
+
53
+
54
+ export const useSchedules = ({ schDay = 1, idStore = '' }) => {
55
+ const {
56
+ data,
57
+ loading,
58
+ error
59
+ } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay, idStore } })
60
+
61
+ return [data?.getStoreSchedules, { loading, error }]
62
+ }
63
+
64
+ export const useCreateSchedules = () => {
65
+ const [setStoreSchedule, { loading, error }] = useMutation(CREATE_STORE_CALENDAR, {
66
+ onError: (e) => {
67
+ console.error(e)
68
+ }
69
+ })
70
+
71
+ return [setStoreSchedule, { loading, error }]
72
+ }
@@ -1,23 +1,23 @@
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, idStore = '' }) => {
5
- const {
6
- data,
7
- loading,
8
- error
9
- } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day, idStore } })
10
-
11
- return [data?.getOneStoreSchedules, { loading, error }]
12
- }
13
-
14
- export const useSchedules = ({ schDay = 1, idStore = '' }) => {
15
- const {
16
- data,
17
- loading,
18
- error
19
- } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay, idStore } })
20
-
21
-
22
- return [data?.getStoreSchedules, { loading, error }]
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, idStore = '' }) => {
5
+ const {
6
+ data,
7
+ loading,
8
+ error
9
+ } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day, idStore } })
10
+
11
+ return [data?.getOneStoreSchedules, { loading, error }]
12
+ }
13
+
14
+ export const useSchedules = ({ schDay = 1, idStore = '' }) => {
15
+ const {
16
+ data,
17
+ loading,
18
+ error
19
+ } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay, idStore } })
20
+
21
+
22
+ return [data?.getStoreSchedules, { loading, error }]
23
23
  }
@@ -1,43 +1,43 @@
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
-
36
- export const SET_STATUS_ALL_SCHEDULE_STORE = gql`
37
- mutation setScheduleOpenAll($scheduleOpenAll: Boolean!) {
38
- setScheduleOpenAll(scheduleOpenAll: $scheduleOpenAll) {
39
- success
40
- message
41
- }
42
- }
43
- `
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
+
36
+ export const SET_STATUS_ALL_SCHEDULE_STORE = gql`
37
+ mutation setScheduleOpenAll($scheduleOpenAll: Boolean!) {
38
+ setScheduleOpenAll(scheduleOpenAll: $scheduleOpenAll) {
39
+ success
40
+ message
41
+ }
42
+ }
43
+ `
@@ -1,123 +1,123 @@
1
- export function useScheduleData (data) {
2
- const days = {
3
- 1: 'Lunes',
4
- 2: 'Martes',
5
- 3: 'Miércoles',
6
- 4: 'Jueves',
7
- 5: 'Viernes',
8
- 6: 'Sabado',
9
- 0: 'Domingo'
10
- }
11
-
12
- const daysArray = [
13
- { day: 0, schHoSta: '', schHoEnd: '' },
14
- { day: 1, schHoSta: '', schHoEnd: '' },
15
- { day: 2, schHoSta: '', schHoEnd: '' },
16
- { day: 3, schHoSta: '', schHoEnd: '' },
17
- { day: 4, schHoSta: '', schHoEnd: '' },
18
- { day: 5, schHoSta: '', schHoEnd: '' },
19
- { day: 6, schHoSta: '', schHoEnd: '' }
20
- ]
21
-
22
- const combinedArray = daysArray.map((dayObj) => {
23
- const originalObj = data?.find((item) => item.schDay === dayObj.day)
24
- return originalObj || { ...dayObj }
25
- })
26
-
27
- // Encontrar la hora de inicio más temprana en combinedArray
28
- const earliestStartTime = Math.min(
29
- ...combinedArray.map((item) => {
30
- const time = new Date(`2023-08-01 ${item.schHoSta}`)
31
- return time.getTime()
32
- })
33
- )
34
-
35
- const calculateYPosition = (start) => {
36
- const time = new Date(`2023-08-01 ${start}`)
37
- const differenceInMinutes = (time.getTime() - earliestStartTime) / (1000 * 40)
38
- return differenceInMinutes / 40 // Ajusta el valor para adaptarse a la posición deseada en el eje Y
39
- }
40
-
41
- /**
42
- * Calcula la duración en horas entre dos horas de inicio y final.
43
- * @param {string} startTime - Hora de inicio en formato 'HH:mm'.
44
- * @param {string} endTime - Hora de fin en formato 'HH:mm'.
45
- * @returns {number} Duración en horas con dos decimales.
46
- */
47
-
48
- // Función para calcular la duración en horas de un horario
49
- function calculateDurationInHours (startTime, endTime) {
50
- const startHour = new Date(`2000-01-01T${startTime}`)
51
- const endHour = new Date(`2000-01-01T${endTime}`)
52
- const duration = (endHour - startHour) / (1000 * 40 * 40) // Convertir la diferencia en horas
53
- return duration.toFixed(2) // Redondear a 2 decimales
54
- }
55
-
56
- // Variables para controlar la posición en el eje X
57
- const columnIndex = 0
58
- const lastDay = -1
59
- const uniqueHoursSet = new Set([
60
- ...combinedArray.map((item) => item.schHoSta),
61
- ...combinedArray.map((item) => item.schHoEnd)
62
- ])
63
-
64
- const uniqueHours = []
65
- for (const hour of uniqueHoursSet) {
66
- const time = new Date(`2023-08-01 ${hour}`)
67
- const formattedHour = time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
68
- uniqueHours.push(formattedHour)
69
- }
70
-
71
- uniqueHours.sort((a, b) => {
72
- const timeA = new Date(`2023-08-01 ${a}`)
73
- const timeB = new Date(`2023-08-01 ${b}`)
74
- return timeA - timeB
75
- })
76
-
77
- // Agregar las horas que faltan al final del día
78
- if (uniqueHours.length > 0) {
79
- const lastHour = new Date(`2023-08-01 ${uniqueHours[uniqueHours.length - 1]}`)
80
- const endTime = new Date(`2023-08-01 ${combinedArray[0].schHoEnd}`)
81
- const hoursDifference = (endTime - lastHour) / (1000 * 60 * 60)
82
-
83
- for (let i = 1; i <= hoursDifference; i++) {
84
- const newHour = new Date(lastHour.getTime() + i * 60 * 60 * 1000)
85
- const formattedNewHour = newHour.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
86
- uniqueHours.push(formattedNewHour)
87
- }
88
- }
89
-
90
- const dayWidth = 120
91
- const daysWithHours = Array.from(new Set(combinedArray.map((item) => (item.schDay !== undefined ? item.schDay : item.day))))
92
- const totalDays = daysWithHours.length
93
- const totalWidth = totalDays * dayWidth
94
-
95
- const sortedUniqueHours = Array.from(uniqueHoursSet)
96
- .sort((a, b) => {
97
- const timeA = new Date(`2023-08-01 ${a}`)
98
- const timeB = new Date(`2023-08-01 ${b}`)
99
- return timeA - timeB
100
- })
101
-
102
- const formattedHours = sortedUniqueHours
103
-
104
- function calculateTimeLinesHeight () {
105
- const totalHours = uniqueHours.length
106
- return totalHours * 60 // Cada hora ocupa 60 píxeles de altura
107
- }
108
- return {
109
- columnIndex,
110
- combinedArray,
111
- days,
112
- daysArray,
113
- daysWithHours,
114
- dayWidth,
115
- lastDay,
116
- totalWidth,
117
- sortedUniqueHours,
118
- uniqueHours: formattedHours,
119
- calculateDurationInHours,
120
- calculateTimeLinesHeight,
121
- calculateYPosition
122
- }
123
- }
1
+ export function useScheduleData (data) {
2
+ const days = {
3
+ 1: 'Lunes',
4
+ 2: 'Martes',
5
+ 3: 'Miércoles',
6
+ 4: 'Jueves',
7
+ 5: 'Viernes',
8
+ 6: 'Sabado',
9
+ 0: 'Domingo'
10
+ }
11
+
12
+ const daysArray = [
13
+ { day: 0, schHoSta: '', schHoEnd: '' },
14
+ { day: 1, schHoSta: '', schHoEnd: '' },
15
+ { day: 2, schHoSta: '', schHoEnd: '' },
16
+ { day: 3, schHoSta: '', schHoEnd: '' },
17
+ { day: 4, schHoSta: '', schHoEnd: '' },
18
+ { day: 5, schHoSta: '', schHoEnd: '' },
19
+ { day: 6, schHoSta: '', schHoEnd: '' }
20
+ ]
21
+
22
+ const combinedArray = daysArray.map((dayObj) => {
23
+ const originalObj = data?.find((item) => item.schDay === dayObj.day)
24
+ return originalObj || { ...dayObj }
25
+ })
26
+
27
+ // Encontrar la hora de inicio más temprana en combinedArray
28
+ const earliestStartTime = Math.min(
29
+ ...combinedArray.map((item) => {
30
+ const time = new Date(`2023-08-01 ${item.schHoSta}`)
31
+ return time.getTime()
32
+ })
33
+ )
34
+
35
+ const calculateYPosition = (start) => {
36
+ const time = new Date(`2023-08-01 ${start}`)
37
+ const differenceInMinutes = (time.getTime() - earliestStartTime) / (1000 * 40)
38
+ return differenceInMinutes / 40 // Ajusta el valor para adaptarse a la posición deseada en el eje Y
39
+ }
40
+
41
+ /**
42
+ * Calcula la duración en horas entre dos horas de inicio y final.
43
+ * @param {string} startTime - Hora de inicio en formato 'HH:mm'.
44
+ * @param {string} endTime - Hora de fin en formato 'HH:mm'.
45
+ * @returns {number} Duración en horas con dos decimales.
46
+ */
47
+
48
+ // Función para calcular la duración en horas de un horario
49
+ function calculateDurationInHours (startTime, endTime) {
50
+ const startHour = new Date(`2000-01-01T${startTime}`)
51
+ const endHour = new Date(`2000-01-01T${endTime}`)
52
+ const duration = (endHour - startHour) / (1000 * 40 * 40) // Convertir la diferencia en horas
53
+ return duration.toFixed(2) // Redondear a 2 decimales
54
+ }
55
+
56
+ // Variables para controlar la posición en el eje X
57
+ const columnIndex = 0
58
+ const lastDay = -1
59
+ const uniqueHoursSet = new Set([
60
+ ...combinedArray.map((item) => item.schHoSta),
61
+ ...combinedArray.map((item) => item.schHoEnd)
62
+ ])
63
+
64
+ const uniqueHours = []
65
+ for (const hour of uniqueHoursSet) {
66
+ const time = new Date(`2023-08-01 ${hour}`)
67
+ const formattedHour = time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
68
+ uniqueHours.push(formattedHour)
69
+ }
70
+
71
+ uniqueHours.sort((a, b) => {
72
+ const timeA = new Date(`2023-08-01 ${a}`)
73
+ const timeB = new Date(`2023-08-01 ${b}`)
74
+ return timeA - timeB
75
+ })
76
+
77
+ // Agregar las horas que faltan al final del día
78
+ if (uniqueHours.length > 0) {
79
+ const lastHour = new Date(`2023-08-01 ${uniqueHours[uniqueHours.length - 1]}`)
80
+ const endTime = new Date(`2023-08-01 ${combinedArray[0].schHoEnd}`)
81
+ const hoursDifference = (endTime - lastHour) / (1000 * 60 * 60)
82
+
83
+ for (let i = 1; i <= hoursDifference; i++) {
84
+ const newHour = new Date(lastHour.getTime() + i * 60 * 60 * 1000)
85
+ const formattedNewHour = newHour.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
86
+ uniqueHours.push(formattedNewHour)
87
+ }
88
+ }
89
+
90
+ const dayWidth = 120
91
+ const daysWithHours = Array.from(new Set(combinedArray.map((item) => (item.schDay !== undefined ? item.schDay : item.day))))
92
+ const totalDays = daysWithHours.length
93
+ const totalWidth = totalDays * dayWidth
94
+
95
+ const sortedUniqueHours = Array.from(uniqueHoursSet)
96
+ .sort((a, b) => {
97
+ const timeA = new Date(`2023-08-01 ${a}`)
98
+ const timeB = new Date(`2023-08-01 ${b}`)
99
+ return timeA - timeB
100
+ })
101
+
102
+ const formattedHours = sortedUniqueHours
103
+
104
+ function calculateTimeLinesHeight () {
105
+ const totalHours = uniqueHours.length
106
+ return totalHours * 60 // Cada hora ocupa 60 píxeles de altura
107
+ }
108
+ return {
109
+ columnIndex,
110
+ combinedArray,
111
+ days,
112
+ daysArray,
113
+ daysWithHours,
114
+ dayWidth,
115
+ lastDay,
116
+ totalWidth,
117
+ sortedUniqueHours,
118
+ uniqueHours: formattedHours,
119
+ calculateDurationInHours,
120
+ calculateTimeLinesHeight,
121
+ calculateYPosition
122
+ }
123
+ }
@@ -1,56 +1,56 @@
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
- export const useScrollColor = () => {
18
- const [scrollNav, setScrollNav] = useState(false)
19
- const changeNav = () => {
20
- if (window?.scrollY >= 1) {
21
- setScrollNav(true)
22
- } else {
23
- setScrollNav(false)
24
- }
25
- }
26
- useEffect(() => {
27
- window.addEventListener('scroll', changeNav)
28
- }, [])
29
- return {
30
- scrollNav
31
- }
32
- }
33
-
34
- export const useScrollHook = () => {
35
- const [style, setStyle] = useState({})
36
-
37
- useEffect(() => {
38
- let scrollPos = 0
39
- const handleChangeHeaderStyle = () => {
40
- if (document.body?.getBoundingClientRect && document.body.getBoundingClientRect().top > scrollPos) {
41
- setStyle({})
42
- } else {
43
- setStyle({ transform: 'translateY(-300%)' })
44
- }
45
- scrollPos = document.body.getBoundingClientRect().top
46
- }
47
-
48
- window.addEventListener('scroll', handleChangeHeaderStyle)
49
-
50
- return () => {
51
- window.removeEventListener('scroll', handleChangeHeaderStyle)
52
- }
53
- }, [])
54
-
55
- return style
56
- }
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
+ export const useScrollColor = () => {
18
+ const [scrollNav, setScrollNav] = useState(false)
19
+ const changeNav = () => {
20
+ if (window?.scrollY >= 1) {
21
+ setScrollNav(true)
22
+ } else {
23
+ setScrollNav(false)
24
+ }
25
+ }
26
+ useEffect(() => {
27
+ window.addEventListener('scroll', changeNav)
28
+ }, [])
29
+ return {
30
+ scrollNav
31
+ }
32
+ }
33
+
34
+ export const useScrollHook = () => {
35
+ const [style, setStyle] = useState({})
36
+
37
+ useEffect(() => {
38
+ let scrollPos = 0
39
+ const handleChangeHeaderStyle = () => {
40
+ if (document.body?.getBoundingClientRect && document.body.getBoundingClientRect().top > scrollPos) {
41
+ setStyle({})
42
+ } else {
43
+ setStyle({ transform: 'translateY(-300%)' })
44
+ }
45
+ scrollPos = document.body.getBoundingClientRect().top
46
+ }
47
+
48
+ window.addEventListener('scroll', handleChangeHeaderStyle)
49
+
50
+ return () => {
51
+ window.removeEventListener('scroll', handleChangeHeaderStyle)
52
+ }
53
+ }, [])
54
+
55
+ return style
56
+ }
@@ -1,16 +1,16 @@
1
- import { useEffect, useState } from 'react'
2
-
3
- // Función scroll Para rotar
4
- export const useScrollRotate = () => {
5
- const [position, setPosition] = useState(0)
6
-
7
- useEffect(() => {
8
- const handleScroll = () => { return setPosition(window.scrollY) }
9
- window.addEventListener('scroll', handleScroll)
10
- return () => {
11
- window.removeEventListener('scroll', handleScroll)
12
- }
13
- }, [])
14
-
15
- return { position }
16
- }
1
+ import { useEffect, useState } from 'react'
2
+
3
+ // Función scroll Para rotar
4
+ export const useScrollRotate = () => {
5
+ const [position, setPosition] = useState(0)
6
+
7
+ useEffect(() => {
8
+ const handleScroll = () => { return setPosition(window.scrollY) }
9
+ window.addEventListener('scroll', handleScroll)
10
+ return () => {
11
+ window.removeEventListener('scroll', handleScroll)
12
+ }
13
+ }, [])
14
+
15
+ return { position }
16
+ }