npm-pkg-hook 1.7.0 → 1.7.1

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.
package/package.json CHANGED
@@ -44,5 +44,5 @@
44
44
  "rm": "rm -rf node_modules package-lock.json && npm i",
45
45
  "test": "echo \"Error: no test specified\" && exit 1"
46
46
  },
47
- "version": "1.7.0"
47
+ "version": "1.7.1"
48
48
  }
@@ -92,7 +92,7 @@ export const statusOpenStores = ({
92
92
  if (findNextDay && findDataNextDay?.schHoSta) {
93
93
  const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow]
94
94
  return handleState(
95
- `Cerrado - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
95
+ `Cerrado abre - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
96
96
  findDataNextDay?.schHoSta ? findDataNextDay?.schHoSta : ''
97
97
  }`,
98
98
  false
@@ -11,23 +11,36 @@ import { calculateTotalPrice } from './helpers'
11
11
  import { statusOpenStores } from '../statusOpenStores'
12
12
  export * from './helpers'
13
13
 
14
- /**
15
- * Custom hook for managing the shopping cart functionality.
16
- * @param {Object} props - Props to control various UI elements.
17
- * @param {function} props.setCountItemProduct - Function to set the count of items in the cart.
18
- * @param {function} props.setAlertBox - Function to set an alert message.
19
- * @param {function} props.handleMenu - Function to handle cart menu visibility.
20
- * @returns {Object} An object with various shopping cart-related functions and data.
21
- */
22
14
  export const useAsideCart = ({
23
15
  openModalProduct = false,
24
- location = {},
16
+ location = {
17
+ pathname: '',
18
+ push: (props, state, { shallow }) => {
19
+ return { ...props, state, shallow }
20
+ },
21
+ query: {
22
+ plato: ''
23
+ }
24
+ },
25
25
  setCountItemProduct = (number) => { return number },
26
- setAlertBox = () => { },
26
+ setAlertBox = (args) => { return args },
27
27
  setOpenModalProduct = () => { },
28
- handleMenu = () => { }
28
+ handleMenu = (boolean) => { return boolean }
29
29
  } = {
30
-
30
+ openModalProduct: false,
31
+ location: {
32
+ pathname: '',
33
+ push: (props, state, { shallow }) => {
34
+ return { ...props, state, shallow }
35
+ },
36
+ query: {
37
+ plato: ''
38
+ }
39
+ },
40
+ setCountItemProduct: (number) => { return number },
41
+ setAlertBox: () => { },
42
+ setOpenModalProduct: () => { },
43
+ handleMenu: () => { }
31
44
  }) => {
32
45
  const { getOneProduct } = useCart({
33
46
  handleMenu,
@@ -137,9 +150,9 @@ export const useAsideCart = ({
137
150
  */
138
151
  const sumProduct = (ProPrice, ProDelivery, cant) => {
139
152
  // Convertir a números, con manejo de posibles errores
140
- const price = parseInt(ProPrice)
141
- const delivery = parseInt(ProDelivery || 0)
142
- const quantity = parseInt(cant)
153
+ const price = ProPrice
154
+ const delivery = ProDelivery || 0
155
+ const quantity = cant
143
156
 
144
157
  // Verificar si las conversiones fueron exitosas
145
158
  if (isNaN(price) || isNaN(delivery) || isNaN(quantity)) {
@@ -1,4 +1,5 @@
1
1
  import { useEffect } from 'react'
2
+
2
3
  export const on = ({ eventType, callBack }) => {
3
4
  document.addEventListener(eventType, callBack)
4
5
  }
@@ -1,38 +1,46 @@
1
- /* eslint-disable no-void */
2
1
  import { useEffect, useState } from 'react'
3
2
 
4
3
  export const useMobile = (props) => {
5
- const { callBack = () => { return null } } = props || {}
6
- const [innerHeight, setInnerHeight] = useState()
7
- const [innerWidth, setInnerWidth] = useState()
8
- let isMobile = false
9
- useEffect(() => {
10
- setInnerHeight(window.innerHeight)
11
- setInnerWidth(window.innerWidth)
12
- callBack()
13
- }, [])
4
+ const { callBack = () => {} } = props || {}
5
+ const [isMobile, setIsMobile] = useState(false)
6
+ const [isTablet, setIsTablet] = useState(false)
7
+ const [innerHeight, setInnerHeight] = useState(0)
8
+ const [innerWidth, setInnerWidth] = useState(0)
9
+
14
10
  useEffect(() => {
15
11
  const handleResize = () => {
16
- if (!isNaN(window === null || window === void 0 ? void 0 : window.innerHeight) && (window === null || window === void 0 ? void 0 : window.innerHeight) !== innerHeight) {
17
- setInnerHeight(window.innerHeight)
18
- }
19
- if (!isNaN(window.innerWidth) && window.innerWidth !== innerWidth) {
20
- setInnerWidth(window.innerWidth)
12
+ // Verificar si window está disponible (es decir, estamos en el lado del cliente)
13
+ if (typeof window !== 'undefined') {
14
+ const width = window.innerWidth
15
+ const height = window.innerHeight
16
+ setInnerWidth(width)
17
+ setInnerHeight(height)
18
+ callBack()
19
+
20
+ // Determinar el tipo de dispositivo
21
+ if (width <= 768) {
22
+ setIsTablet(true)
23
+ } else if (width <= 960) {
24
+ setIsMobile(true)
25
+ } else {
26
+ setIsMobile(false)
27
+ }
21
28
  }
22
- callBack()
23
- }
24
- if (typeof window !== 'undefined') {
25
- window.addEventListener('resize', handleResize)
26
29
  }
30
+
31
+ // Ejecutar handleResize al cargar y al cambiar el tamaño de la pantalla
32
+ handleResize()
33
+ window.addEventListener('resize', handleResize)
34
+
35
+ // Eliminar el event listener al desmontar el componente
27
36
  return () => {
28
37
  window.removeEventListener('resize', handleResize)
29
38
  }
30
- })
31
- if (typeof window !== 'undefined' && /Mobile/i.test((navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor))) {
32
- isMobile = true
33
- }
39
+ }, [callBack])
40
+
34
41
  return {
35
42
  isMobile,
43
+ isTablet,
36
44
  innerHeight,
37
45
  innerWidth
38
46
  }
@@ -56,7 +56,7 @@ const initializer = (initialValue = initialState) => {
56
56
  export const useSales = ({
57
57
  disabled = false,
58
58
  router,
59
- sendNotification = () => { return },
59
+ sendNotification = (arsg) => { return arsg },
60
60
  setAlertBox = () => { return }
61
61
  }) => {
62
62
  const domain = getCurrentDomain()
@@ -104,7 +104,6 @@ export const useSales = ({
104
104
  const [loadingExtraProduct, setLoadingExtraProduct] = useState(false)
105
105
  const [dataOptional, setDataOptional] = useState([])
106
106
  const [dataExtra, setDataExtra] = useState([])
107
-
108
107
  const [registerSalesStore, { loading: loadingRegisterSale }] = useMutation(
109
108
  CREATE_SHOPPING_CARD_TO_USER_STORE,
110
109
  {
@@ -94,7 +94,7 @@ export const useStatusOpenStore = ({ dataSchedules = [] } = {}) => {
94
94
  if (findNextDay && findDataNextDay?.schHoSta) {
95
95
  const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow]
96
96
  return handleMessageHour(
97
- `Cerrado - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
97
+ `Cerrado abre Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
98
98
  findDataNextDay?.schHoSta ? findDataNextDay?.schHoSta : ''
99
99
  }`,
100
100
  false