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
|
@@ -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 = ({
|
|
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
|
|
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
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
|
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.
|
|
File without changes
|