npm-pkg-hook 1.8.5 → 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
@@ -45,5 +45,5 @@
45
45
  "rm": "rm -rf node_modules package-lock.json && npm i",
46
46
  "test": "echo \"Error: no test specified\" && exit 1"
47
47
  },
48
- "version": "1.8.5"
48
+ "version": "1.8.6"
49
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
- sendNotification = () => { }
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.click()
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
- const formatPrice = ProPrice ? parseFloat(ProPrice?.replace(/\./g, '')) : 0
144
- if (!carProId && !names) return setErrors({ ...errors, carProId: true })
145
-
146
- if (!ProPrice?.length > 0) {
147
- return setErrors({ ...errors, ProPrice: true })
163
+ } = values ?? {
164
+ ProPrice: 0,
165
+ ProDescuento: 0,
166
+ ProDescription: '',
167
+ ProWeight: '',
168
+ ProHeight: 0,
169
+ ValueDelivery: 0,
170
+ carProId: ''
148
171
  }
149
- const ProImage = `https:${process.env.URL_ADMIN_SERVER}static/platos/${image?.name}`
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 : parseInt(ProDescuento),
158
- ValueDelivery: check?.desc ? 0 : parseFloat(ValueDelivery),
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 (dataOld = {}) {
204
+ getCatProductsWithProduct () {
180
205
  const updatedData = getCatProductsWithProduct(data, carProId)
181
206
  return updatedData
182
207
  }
183
208
  }
184
209
  })
185
210
  }
186
- }).then((res) => {
187
- const { updateProductFoods } = res?.data || {}
188
- const { pId } = updateProductFoods || {}
189
- setPid(pId ?? null)
190
- router.push(
191
- {
192
- query: {
193
- ...router.query,
194
- food: pId
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
- setImageProducts({
221
- variables: {
222
- input: {
223
- file: image,
224
- pCode
223
+ try {
224
+ await setImageProducts({
225
+ variables: {
226
+ input: {
227
+ file: image,
228
+ pCode
229
+ }
225
230
  }
226
- }
227
- }).then(() => {
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
@@ -324,8 +324,22 @@ export const UPDATE_IMAGE_PRODUCT_FOOD = gql`
324
324
  }
325
325
  `
326
326
  export const UPDATE_PRODUCT_FOOD = gql`
327
- mutation updateProductFoods($input: InputProductFood) {
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