npm-pkg-hook 1.4.4 → 1.4.5

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
@@ -43,5 +43,5 @@
43
43
  "rm": "rm -rf node_modules package-lock.json && npm i",
44
44
  "test": "echo \"Error: no test specified\" && exit 1"
45
45
  },
46
- "version": "1.4.4"
46
+ "version": "1.4.5"
47
47
  }
@@ -6,7 +6,12 @@
6
6
  * @param {string} idStore - The ID of the store
7
7
  * @returns {string} - The generated URL or null if any field is missing
8
8
  */
9
- export const generateStoreURL = ({ city, department, storeName, idStore }) => {
9
+ export const generateStoreURL = ({
10
+ city,
11
+ department,
12
+ storeName,
13
+ idStore
14
+ }) => {
10
15
  try {
11
16
  // Validate all necessary fields
12
17
  if (
@@ -16,7 +21,7 @@ export const generateStoreURL = ({ city, department, storeName, idStore }) => {
16
21
  !storeName ||
17
22
  !idStore
18
23
  ) {
19
- return null // Return null or any default case you'd prefer
24
+ return '/' // Return null or any default case you'd prefer
20
25
  }
21
26
 
22
27
  const cityName = city.cName.toLocaleLowerCase()
@@ -27,6 +32,6 @@ export const generateStoreURL = ({ city, department, storeName, idStore }) => {
27
32
 
28
33
  return `${process.env.MAIN_URL_BASE}/delivery/${cityName}-${departmentName}/${formattedStoreName}/${idStore}`
29
34
  } catch (_) {
30
- return null
35
+ return '/'
31
36
  }
32
37
  }
@@ -61,7 +61,6 @@ export const useAsideCart = ({
61
61
  setTotalProductPrice(Math.abs(totalPrice))
62
62
  }, [dataShoppingCard])
63
63
 
64
- console.log(dataShoppingCard)
65
64
  const [deleteOneItem] = useMutation(DELETE_ONE_ITEM_SHOPPING_PRODUCT, {
66
65
  onCompleted: data => {
67
66
  setAlertBox({ message: data?.deleteOneItem?.message })
@@ -82,53 +81,45 @@ export const useAsideCart = ({
82
81
  }
83
82
  }
84
83
  /**
85
- * Handle the deletion of a shopping cart item.
86
- * @param {Object} item - The item to be deleted from the shopping cart.
87
- */
84
+ * Handle the deletion of a shopping cart item.
85
+ * @param {Object} item - The item to be deleted from the shopping cart.
86
+ */
88
87
  const handleDeleteItemShopping = async (item) => {
88
+ if (!item) {
89
+ return setAlertBox({
90
+ message: 'Error borrando el producto. Por favor intenta nuevamente.',
91
+ color: 'error'
92
+ })
93
+ }
94
+
89
95
  try {
90
96
  const { cState, ShoppingCard } = item
91
97
  await deleteOneItem({
92
- variables: {
93
- cState,
94
- ShoppingCard
95
- },
96
- update: (cache, { data }) => {
97
- const success = data?.deleteOneItem?.success
98
- if (success && ShoppingCard) {
99
- cache.modify({
100
- fields: {
101
- getAllShoppingCard (existingCart, { readField }) {
102
- if (Array.isArray(existingCart) && existingCart) {
103
- if (existingCart.length === 1) {
104
- setCountItemProduct(0)
105
- }
106
- const updatedCart = {
107
- ...existingCart,
108
- ...existingCart?.filter(product =>
109
- readField('ShoppingCard', product) !== ShoppingCard
110
- )
111
- }
112
- if (typeof updatedCart === 'object' && updatedCart !== null) {
113
- const newLength = Object.keys(updatedCart)
114
- if (updatedCart && newLength) {
115
- setCountItemProduct(Object.keys(updatedCart).length)
116
- }
117
- }
118
- return updatedCart
119
- } else {
120
- return []
121
- }
122
- }
98
+ variables: { cState, ShoppingCard },
99
+ update: (cache) => {
100
+ cache.modify({
101
+ fields: {
102
+ getAllShoppingCard (existingCart, { readField }) {
103
+ if (!Array.isArray(existingCart)) return []
104
+
105
+ const filteredCart = existingCart.filter(product =>
106
+ readField('ShoppingCard', product) !== ShoppingCard
107
+ )
108
+
109
+ // Actualizar el contador de productos
110
+ setCountItemProduct(filteredCart.length)
111
+
112
+ return filteredCart?.length > 0 ? filteredCart : []
123
113
  }
124
- })
125
- }
114
+ }
115
+ })
126
116
  }
127
117
  })
128
118
  } catch (error) {
129
- setAlertBox({ message: 'Error borranto el item. Por favor intenta nuevamente.', color: 'error' })
119
+ setAlertBox({ message: 'Error borrando el producto. Por favor intenta nuevamente.', color: 'error' })
130
120
  }
131
121
  }
122
+
132
123
  /**
133
124
  * Calculate the total price of a product.
134
125
  * @param {number} ProPrice - The price of the product.
@@ -1,6 +1,6 @@
1
1
  import { useApolloClient } from '@apollo/client'
2
2
  import { useState } from 'react'
3
- import { Cookies } from '../../cookies'
3
+ import { Cookies } from '../../cookies/index'
4
4
  import { signOutAuth } from './helpers'
5
5
  export { signOutAuth } from './helpers'
6
6
 
File without changes