npm-pkg-hook 1.8.4 → 1.8.6
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,10 +6,11 @@
|
|
|
6
6
|
"js-cookie": "3.0.1",
|
|
7
7
|
"lodash": "^4.17.21",
|
|
8
8
|
"md5": "2.3.0",
|
|
9
|
-
"moment": "^2.29.4",
|
|
9
|
+
"moment": "^2.29.4",
|
|
10
10
|
"react": "18.1.0",
|
|
11
11
|
"react-dom": "18.1.0",
|
|
12
|
-
"react-query": "^3.39.2"
|
|
12
|
+
"react-query": "^3.39.2",
|
|
13
|
+
"react-responsive": "^10.0.0"
|
|
13
14
|
},
|
|
14
15
|
"description": "description-pkg-hook",
|
|
15
16
|
"devDependencies": {
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"license": "ISC",
|
|
32
33
|
"main": "/src/index.jsx",
|
|
33
|
-
"name": "npm-pkg-hook",
|
|
34
|
+
"name": "npm-pkg-hook",
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"registry": "https://registry.npmjs.org/"
|
|
36
37
|
},
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"rm": "rm -rf node_modules package-lock.json && npm i",
|
|
45
46
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
46
47
|
},
|
|
47
|
-
"version": "1.8.
|
|
48
|
+
"version": "1.8.6"
|
|
48
49
|
}
|
|
@@ -15,14 +15,28 @@ import { getCatProductsWithProduct } from './helpers/manageCacheDataCatProduct'
|
|
|
15
15
|
export * from './helpers'
|
|
16
16
|
|
|
17
17
|
export const useCreateProduct = ({
|
|
18
|
-
setAlertBox = () => { },
|
|
19
18
|
router,
|
|
20
|
-
|
|
19
|
+
setAlertBox = (args) => { return args },
|
|
20
|
+
sendNotification = (args) => { return args }
|
|
21
21
|
}) => {
|
|
22
22
|
const [errors, setErrors] = useState({
|
|
23
|
-
names:
|
|
23
|
+
names: false,
|
|
24
|
+
ProPrice: false,
|
|
25
|
+
ProDescuento: false,
|
|
26
|
+
ProDescription: false,
|
|
27
|
+
ProWeight: false,
|
|
28
|
+
ProHeight: false,
|
|
29
|
+
ValueDelivery: false
|
|
30
|
+
})
|
|
31
|
+
const [values, setValues] = useState({
|
|
32
|
+
ProPrice: 0,
|
|
33
|
+
ProDescuento: 0,
|
|
34
|
+
ProDescription: '',
|
|
35
|
+
ProWeight: '',
|
|
36
|
+
ProHeight: '',
|
|
37
|
+
ValueDelivery: 0,
|
|
38
|
+
carProId: ''
|
|
24
39
|
})
|
|
25
|
-
const [values, setValues] = useState({})
|
|
26
40
|
const [names, setName] = useLocalStorage('namefood', '')
|
|
27
41
|
const [showMore, setShowMore] = useState(50)
|
|
28
42
|
const [search, setSearch] = useState('')
|
|
@@ -49,7 +63,9 @@ export const useCreateProduct = ({
|
|
|
49
63
|
// HANDLESS
|
|
50
64
|
const [check, setCheck] = useState({
|
|
51
65
|
availability: true,
|
|
52
|
-
noAvailability: false
|
|
66
|
+
noAvailability: false,
|
|
67
|
+
desc: false,
|
|
68
|
+
freeShipping: false
|
|
53
69
|
})
|
|
54
70
|
|
|
55
71
|
const handleCheck = (e) => {
|
|
@@ -79,7 +95,11 @@ export const useCreateProduct = ({
|
|
|
79
95
|
setSearchFilter({ ...filter })
|
|
80
96
|
}
|
|
81
97
|
const onClickClear = () => {
|
|
82
|
-
setSearchFilter({
|
|
98
|
+
setSearchFilter({
|
|
99
|
+
gender: [],
|
|
100
|
+
desc: [],
|
|
101
|
+
speciality: []
|
|
102
|
+
})
|
|
83
103
|
}
|
|
84
104
|
const handleChangeClick = e => {
|
|
85
105
|
const {
|
|
@@ -96,7 +116,7 @@ export const useCreateProduct = ({
|
|
|
96
116
|
handleCheck(e)
|
|
97
117
|
setValues({
|
|
98
118
|
...values,
|
|
99
|
-
ValueDelivery:
|
|
119
|
+
ValueDelivery: 0
|
|
100
120
|
})
|
|
101
121
|
}
|
|
102
122
|
|
|
@@ -112,7 +132,6 @@ export const useCreateProduct = ({
|
|
|
112
132
|
const file = event.target.files[0]
|
|
113
133
|
setImage(file)
|
|
114
134
|
const base64 = await convertBase64(file)
|
|
115
|
-
// eslint-disable-next-line
|
|
116
135
|
// const [size, { unit }] = await getFileSizeByUnit(file, "B");
|
|
117
136
|
setImageBase64(base64)
|
|
118
137
|
setPreviewImg(
|
|
@@ -125,7 +144,9 @@ export const useCreateProduct = ({
|
|
|
125
144
|
)
|
|
126
145
|
}
|
|
127
146
|
const onTargetClick = () => {
|
|
128
|
-
fileInputRef.current
|
|
147
|
+
if (fileInputRef.current) {
|
|
148
|
+
fileInputRef.current.click()
|
|
149
|
+
}
|
|
129
150
|
}
|
|
130
151
|
// eslint-disable-next-line no-unused-vars
|
|
131
152
|
const { img } = useEditImageProduct({ sendNotification, initialState })
|
|
@@ -139,23 +160,27 @@ export const useCreateProduct = ({
|
|
|
139
160
|
ProHeight,
|
|
140
161
|
ValueDelivery,
|
|
141
162
|
carProId
|
|
142
|
-
} = values
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
} = values ?? {
|
|
164
|
+
ProPrice: 0,
|
|
165
|
+
ProDescuento: 0,
|
|
166
|
+
ProDescription: '',
|
|
167
|
+
ProWeight: '',
|
|
168
|
+
ProHeight: 0,
|
|
169
|
+
ValueDelivery: 0,
|
|
170
|
+
carProId: ''
|
|
148
171
|
}
|
|
149
|
-
const
|
|
172
|
+
const formatPrice = ProPrice ?? 0
|
|
173
|
+
if (!carProId && !names) return setErrors({ ...errors, carProId: true })
|
|
174
|
+
const ProImage = `https:${process.env.URL_ADMIN_SERVER}/static/platos/${image?.name}`
|
|
150
175
|
const pCode = RandomCode(9)
|
|
151
176
|
try {
|
|
152
|
-
updateProductFoods({
|
|
177
|
+
const res = await updateProductFoods({
|
|
153
178
|
variables: {
|
|
154
179
|
input: {
|
|
155
180
|
idStore: dataStore?.getStore?.idStore || '',
|
|
156
181
|
ProPrice: check?.desc ? 0 : formatPrice,
|
|
157
|
-
ProDescuento: check?.desc ? 0 :
|
|
158
|
-
ValueDelivery: check?.desc ? 0 :
|
|
182
|
+
ProDescuento: check?.desc ? 0 : ProDescuento,
|
|
183
|
+
ValueDelivery: check?.desc ? 0 : ValueDelivery,
|
|
159
184
|
ProDescription,
|
|
160
185
|
pName: names,
|
|
161
186
|
pCode,
|
|
@@ -176,63 +201,44 @@ export const useCreateProduct = ({
|
|
|
176
201
|
productFoodsAll (dataOld = []) {
|
|
177
202
|
return cache.writeQuery({ query: GET_ALL_FOOD_PRODUCTS, data: dataOld })
|
|
178
203
|
},
|
|
179
|
-
getCatProductsWithProduct (
|
|
204
|
+
getCatProductsWithProduct () {
|
|
180
205
|
const updatedData = getCatProductsWithProduct(data, carProId)
|
|
181
206
|
return updatedData
|
|
182
207
|
}
|
|
183
208
|
}
|
|
184
209
|
})
|
|
185
210
|
}
|
|
186
|
-
}).
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
undefined,
|
|
198
|
-
{ shallow: true }
|
|
199
|
-
)
|
|
200
|
-
sendNotification({
|
|
201
|
-
backgroundColor: 'success',
|
|
202
|
-
title: 'Success',
|
|
203
|
-
description: `El producto ${names} subido con éxito`
|
|
204
|
-
})
|
|
205
|
-
const objTag = {
|
|
206
|
-
aName: tags.tag,
|
|
207
|
-
nameTag: tags.tag,
|
|
208
|
-
pId
|
|
209
|
-
}
|
|
210
|
-
if (tags?.tag) handleRegisterTags(objTag)
|
|
211
|
-
setValues({})
|
|
212
|
-
}).catch(err => {
|
|
213
|
-
return sendNotification({
|
|
214
|
-
backgroundColor: 'error',
|
|
215
|
-
title: `${err}`,
|
|
216
|
-
description: 'Error inesperado'
|
|
211
|
+
}).finally(() => {
|
|
212
|
+
setValues({
|
|
213
|
+
ProPrice: 0,
|
|
214
|
+
ProDescuento: 0,
|
|
215
|
+
ProDescription: '',
|
|
216
|
+
ProWeight: '',
|
|
217
|
+
ProHeight: '',
|
|
218
|
+
ValueDelivery: 0,
|
|
219
|
+
carProId: ''
|
|
217
220
|
})
|
|
218
221
|
})
|
|
219
222
|
if (image !== null) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
try {
|
|
224
|
+
await setImageProducts({
|
|
225
|
+
variables: {
|
|
226
|
+
input: {
|
|
227
|
+
file: image,
|
|
228
|
+
pCode
|
|
229
|
+
}
|
|
225
230
|
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}).catch(() => {
|
|
231
|
+
})
|
|
232
|
+
} catch {
|
|
229
233
|
sendNotification({
|
|
230
234
|
backgroundColor: 'error',
|
|
231
235
|
title: `Ocurrió un error en la imagen en el producto ${names}`,
|
|
232
236
|
description: 'error'
|
|
233
237
|
})
|
|
234
|
-
}
|
|
238
|
+
}
|
|
235
239
|
}
|
|
240
|
+
setPid(res?.data?.updateProductFoods?.data?.pId ?? null)
|
|
241
|
+
return res
|
|
236
242
|
} catch (error) {
|
|
237
243
|
setAlertBox({ message: 'Ha ocurrido un error', duration: 7000 })
|
|
238
244
|
}
|
|
@@ -48,7 +48,7 @@ export const useDessert = ({
|
|
|
48
48
|
// If list or list.cards is missing, assume the list is not complete
|
|
49
49
|
const verifiEmpyRequireCard = list?.cards?.length
|
|
50
50
|
if (list && list?.cards) {
|
|
51
|
-
return verifiEmpyRequireCard === list.numberLimit
|
|
51
|
+
return Number(verifiEmpyRequireCard) === Number(list.numberLimit)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// If list or list.cards is missing, assume the list is not complete
|
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMediaQuery } from 'react-responsive'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const [innerHeight, setInnerHeight] = useState(0)
|
|
8
|
-
const [innerWidth, setInnerWidth] = useState(0)
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const handleResize = () => {
|
|
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
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Ejecutar handleResize al cargar y al cambiar el tamaño de la pantalla
|
|
32
|
-
handleResize()
|
|
33
|
-
window.addEventListener('resize', handleResize)
|
|
3
|
+
export const MEDIA_QUERY = {
|
|
4
|
+
MOBILE: '768px',
|
|
5
|
+
TABLED: '960px'
|
|
6
|
+
}
|
|
34
7
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}, [callBack])
|
|
8
|
+
export const useMobile = () => {
|
|
9
|
+
const isMobile = useMediaQuery({ query: `(max-width: ${MEDIA_QUERY.MOBILE})` })
|
|
10
|
+
const isTablet = useMediaQuery({ query: `(max-width: ${MEDIA_QUERY.TABLED}})` })
|
|
40
11
|
|
|
41
12
|
return {
|
|
42
13
|
isMobile,
|
|
43
|
-
isTablet
|
|
44
|
-
innerHeight,
|
|
45
|
-
innerWidth
|
|
14
|
+
isTablet
|
|
46
15
|
}
|
|
47
16
|
}
|
|
@@ -324,8 +324,22 @@ export const UPDATE_IMAGE_PRODUCT_FOOD = gql`
|
|
|
324
324
|
}
|
|
325
325
|
`
|
|
326
326
|
export const UPDATE_PRODUCT_FOOD = gql`
|
|
327
|
-
|
|
327
|
+
mutation updateProductFoods($input: InputProductFood) {
|
|
328
328
|
updateProductFoods(input: $input) {
|
|
329
|
+
success
|
|
330
|
+
message
|
|
331
|
+
errors {
|
|
332
|
+
path
|
|
333
|
+
message
|
|
334
|
+
type
|
|
335
|
+
context {
|
|
336
|
+
limit
|
|
337
|
+
value
|
|
338
|
+
label
|
|
339
|
+
key
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
data {
|
|
329
343
|
pId
|
|
330
344
|
sizeId #Talla
|
|
331
345
|
colorId #Color
|
|
@@ -355,6 +369,7 @@ export const UPDATE_PRODUCT_FOOD = gql`
|
|
|
355
369
|
ProDelivery
|
|
356
370
|
ProVoltaje
|
|
357
371
|
}
|
|
372
|
+
}
|
|
358
373
|
}
|
|
359
374
|
`
|
|
360
375
|
// UPDATE EXTRAS
|