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
@@ -20,13 +20,11 @@ import {
20
20
  GET_ONE_PRODUCTS_FOOD,
21
21
  } from "../useProductsFood/queriesStore";
22
22
  import { useStore } from "../useStore";
23
- import {
24
- CREATE_SHOPPING_CARD_TO_USER_STORE,
25
- GET_ALL_COUNT_SALES,
26
- GET_ALL_PEDIDOS,
27
- GET_ALL_SALES,
28
- GET_ALL_SALES_STATISTICS,
29
- } from "./queries";
23
+ import { CREATE_SHOPPING_CARD_TO_USER_STORE, GET_ALL_COUNT_SALES } from "./queries";
24
+ import { useLogout } from "../useLogout";
25
+ import { updateExistingOrders } from "../useUpdateExistingOrders";
26
+ import { useGetSale } from "../useSales/useGetSale";
27
+ export * from './useGetAllSales'
30
28
 
31
29
  const initialState = {
32
30
  PRODUCT: [],
@@ -51,9 +49,10 @@ const initializer = (initialValue = initialState) => {
51
49
 
52
50
  export const useSales = ({
53
51
  disabled,
54
- sendNotification,
55
52
  router,
56
- setAlertBox,
53
+ sendNotification = () => { return },
54
+ setAlertBox = () => { return },
55
+ setSalesOpen = () => { return },
57
56
  }) => {
58
57
  const domain = getCurrentDomain();
59
58
  const [loadingSale, setLoadingSale] = useState(false);
@@ -84,22 +83,31 @@ export const useSales = ({
84
83
  const [loadingExtraProduct, setLoadingExtraProduct] = useState(false);
85
84
  const [dataOptional, setDataOptional] = useState([]);
86
85
  const [dataExtra, setDataExtra] = useState([]);
86
+ const [onClickLogout] = useLogout({ setAlertBox })
87
87
 
88
88
  const [registerSalesStore, { loading: loadingRegisterSale }] = useMutation(
89
89
  CREATE_SHOPPING_CARD_TO_USER_STORE,
90
90
  {
91
91
  onCompleted: (data) => {
92
92
  const message = `${data?.registerSalesStore?.Response?.message}`;
93
- const error = data?.registerSalesStore?.Response.success
93
+ const isSuccess = data?.registerSalesStore?.Response.success === true
94
+ const error = isSuccess
94
95
  ? "Éxito"
95
96
  : "Error";
97
+ if (message === 'Token expired') {
98
+ setSalesOpen(false)
99
+ onClickLogout()
100
+ }
96
101
  sendNotification({
97
- backgroundColor: error ? 'success' : 'error',
102
+ backgroundColor: isSuccess ? 'success' : 'error',
98
103
  title: error,
99
104
  description: message
100
105
  });
101
106
  setAlertBox({ message: message, type: "success" });
102
- setOpenCurrentSale(data?.registerSalesStore?.Response.success);
107
+
108
+ if (isSuccess) {
109
+ setOpenCurrentSale(isSuccess);
110
+ }
103
111
  },
104
112
  onError: (error) => {
105
113
  console.log(error)
@@ -754,6 +762,7 @@ export const useSales = ({
754
762
  }
755
763
  const totalProductsPrice = totalProductPrice;
756
764
  const client = useApolloClient()
765
+ const { getOnePedidoStore, error: saleError } = useGetSale()
757
766
 
758
767
  const handleSubmit = () => {
759
768
  if (!values?.cliId)
@@ -777,14 +786,15 @@ export const useSales = ({
777
786
  discount: discount.discount || 0,
778
787
  totalProductsPrice: totalProductsPrice || 0,
779
788
  }
780
- })
781
- .then((responseRegisterR) => {
789
+ }).then((responseRegisterR) => {
782
790
  if (responseRegisterR) {
783
791
  const { data } = responseRegisterR || {};
784
792
  const { registerSalesStore } = data || {};
785
793
  const { Response } = registerSalesStore || {};
786
- if (Response && Response.success === true) {
787
- // dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
794
+ const success = Response?.success === true
795
+ if (success) {
796
+ console.log(responseRegisterR)
797
+ if (!process.env.NODE_ENV === 'development') dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
788
798
  client.query({
789
799
  query: GET_ALL_COUNT_SALES,
790
800
  fetchPolicy: 'network-only',
@@ -792,6 +802,28 @@ export const useSales = ({
792
802
  client.writeQuery({ query: GET_ALL_COUNT_SALES, data: { getTodaySales: data.countSales.todaySales } })
793
803
  }
794
804
  })
805
+ getOnePedidoStore({
806
+ variables: {
807
+ pCodeRef: code || ''
808
+ }
809
+ }).then((res) => {
810
+ console.log(res)
811
+ const currentSale = res?.data?.getOnePedidoStore
812
+ if (currentSale && !saleError) {
813
+ client.cache.modify({
814
+ fields: {
815
+ getAllOrdersFromStore(existingOrders = []) {
816
+ try {
817
+ const cache = updateExistingOrders(existingOrders, code, 4, currentSale)
818
+ return cache
819
+ } catch (e) {
820
+ return existingOrders
821
+ }
822
+ }
823
+ }
824
+ })
825
+ }
826
+ })
795
827
  router.push(
796
828
  {
797
829
  query: {
@@ -802,7 +834,7 @@ export const useSales = ({
802
834
  undefined,
803
835
  { shallow: true }
804
836
  );
805
- // setValues({})
837
+ if (!process.env.NODE_ENV === 'development') setValues({})
806
838
  }
807
839
  }
808
840
  setLoadingSale(false);
@@ -830,18 +862,17 @@ export const useSales = ({
830
862
  const optionalAll = await ExtProductFoodsSubOptionalAll({
831
863
  variables: { pId },
832
864
  });
833
- const optionalFetch = optionalAll.data.ExtProductFoodsOptionalAll;
865
+ const optionalFetch = optionalAll?.data?.ExtProductFoodsOptionalAll || [];
834
866
  setDataOptional(optionalFetch || []);
835
867
  const existOptionalCookies = originalArray?.dataOptional;
836
868
  const filteredDataOptional = existOptionalCookies?.length
837
869
  ? existOptionalCookies
838
870
  ?.map((obj) => {
839
- const filteredSubOptions =
840
- obj.ExtProductFoodsSubOptionalAll.filter(
841
- (subObj) => subObj.check === true
871
+ const filteredSubOptions = obj?.ExtProductFoodsSubOptionalAll?.filter(
872
+ (subObj) => subObj?.check === true
842
873
  );
843
874
  // Excluya todo el objeto padre si filteredSubOptions está vacío
844
- if (filteredSubOptions.length === 0) {
875
+ if (filteredSubOptions?.length === 0) {
845
876
  return null;
846
877
  }
847
878
  return {
@@ -94,52 +94,60 @@ export const GET_ALL_SALES_STATISTICS = gql`
94
94
  `;
95
95
 
96
96
  export const GET_ONE_SALES = gql`
97
- query getOnePedidoStore($pCodeRef: String) {
98
- getOnePedidoStore(pCodeRef: $pCodeRef) {
97
+ query getOnePedidoStore($pCodeRef: String) {
98
+ getOnePedidoStore(pCodeRef: $pCodeRef) {
99
+ pdpId
100
+ pCodeRef
101
+ idStore
102
+ pPDate
103
+ channel
104
+ change
105
+ pSState
106
+ pDatCre
107
+ id
108
+ pDatMod
109
+ pPRecoger
110
+ payMethodPState
111
+ pdpId
112
+ totalProductsPrice
113
+ locationUser
114
+ getUser {
115
+ id
116
+ email
117
+ uPhoNum
118
+ ULocation
119
+ }
120
+ getAllPedidoStore {
99
121
  pdpId
100
- pCodeRef
101
122
  idStore
102
- pPDate
103
- channel
104
- pSState
105
- pDatCre
106
- pDatMod
107
- pPRecoger
108
- payMethodPState
109
- pdpId
110
- totalProductsPrice
111
- locationUser
112
- getAllPedidoStore {
113
- pdpId
114
- idStore
115
- pCodeRef
123
+ pCodeRef
124
+ ShoppingCard
125
+ getAllShoppingCard {
116
126
  ShoppingCard
117
- getAllShoppingCard {
118
- ShoppingCard
119
- cantProducts
120
- subProductsId
121
- comments
127
+ cantProducts
128
+ subProductsId
129
+ comments
130
+ pId
131
+ productFood {
122
132
  pId
123
- productFood {
124
- pId
125
- carProId
126
- colorId
127
- idStore
128
- pName
129
- ProPrice
130
- ProDescuento
131
- ProDescription
132
- ValueDelivery
133
- ProImage
134
- ProStar
135
- pState
136
- pDatCre
137
- pDatMod
138
- }
133
+ carProId
134
+ colorId
135
+ idStore
136
+ pName
137
+ ProPrice
138
+ ProDescuento
139
+ ProDescription
140
+ ValueDelivery
141
+ ProImage
142
+ ProStar
143
+ pState
144
+ pDatCre
145
+ pDatMod
139
146
  }
140
147
  }
141
148
  }
142
149
  }
150
+ }
143
151
  `;
144
152
 
145
153
  export const CREATE_CLIENTS = gql`
@@ -258,7 +266,9 @@ export const GET_ONE_SALE = gql`
258
266
  pCodeRef
259
267
  idStore
260
268
  pPDate
269
+ id
261
270
  channel
271
+ change
262
272
  pSState
263
273
  pDatCre
264
274
  pDatMod
@@ -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
+ }