npm-pkg-hook 1.11.3 → 1.11.7

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.
Files changed (82) hide show
  1. package/.env +5 -1
  2. package/package.json +3 -2
  3. package/src/config/client/errors.js +1 -1
  4. package/src/config/content/en.json +5 -0
  5. package/src/config/content/es.json +5 -0
  6. package/src/config/content/index.js +16 -0
  7. package/src/hooks/index.js +6 -0
  8. package/src/hooks/newStoreOrderSubscription/index.js +1 -12
  9. package/src/hooks/updateExtProductFoodsOptional/index.js +2 -2
  10. package/src/hooks/useCatWithProduct/queries.js +50 -24
  11. package/src/hooks/useCategoriesProduct/index.js +1 -0
  12. package/src/hooks/useCategoriesProduct/queries.js +2 -2
  13. package/src/hooks/useCategoryInStore/queries.js +2 -2
  14. package/src/hooks/useClients/queries.js +72 -23
  15. package/src/hooks/useCreateProduct/helpers/index.js +2 -2
  16. package/src/hooks/useCreateProduct/index.js +45 -46
  17. package/src/hooks/useDessert/index.js +20 -3
  18. package/src/hooks/useDessertWithPrice/helpers/index.js +2 -2
  19. package/src/hooks/useDessertWithPrice/index.js +70 -60
  20. package/src/hooks/useDessertWithPrice/queries.js +2 -2
  21. package/src/hooks/useDevices/queries.js +16 -7
  22. package/src/hooks/useDevices/useGetDevices.js +12 -19
  23. package/src/hooks/useDevices/useRegisterDevices.js +3 -3
  24. package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +21 -0
  25. package/src/hooks/useDownloadReports/index.ts +2 -0
  26. package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +103 -0
  27. package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +115 -0
  28. package/src/hooks/useEditCategory/index.js +10 -10
  29. package/src/hooks/useFormTools/index.js +2 -1
  30. package/src/hooks/useFormatDate/index.js +56 -3
  31. package/src/hooks/useGetStoreCookie/index.js +1 -1
  32. package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +130 -0
  33. package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +53 -0
  34. package/src/hooks/useImageUploaderProduct/helper/index.ts +5 -0
  35. package/src/hooks/useImageUploaderProduct/index.ts +292 -0
  36. package/src/hooks/useImagesStore/index.js +100 -58
  37. package/src/hooks/useImagesStore/queries.js +2 -2
  38. package/src/hooks/useImagesStore/utils/index.js +4 -0
  39. package/src/hooks/useInventory/queries.js +1 -1
  40. package/src/hooks/useLocationManager/index.js +3 -1
  41. package/src/hooks/useLogout/helpers/fetchData.js +1 -1
  42. package/src/hooks/useLogout/helpers/logger.js +8 -8
  43. package/src/hooks/useLogout/index.js +6 -4
  44. package/src/hooks/useManageNewOrder/index.js +3 -3
  45. package/src/hooks/useManageQueryParams/index.js +28 -28
  46. package/src/hooks/useMobile/index.js +38 -8
  47. package/src/hooks/useOrderStatusTypes/index.ts +2 -0
  48. package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +52 -0
  49. package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +97 -0
  50. package/src/hooks/useOrders/index.js +2 -74
  51. package/src/hooks/useOrders/queries.js +31 -195
  52. package/src/hooks/useOrders/useChangeOrderState/index.ts +125 -0
  53. package/src/hooks/useOrders/useOrdersFromStore/index.ts +83 -0
  54. package/src/hooks/usePortFetcher/index.ts +33 -0
  55. package/src/hooks/useProductsFood/index.js +3 -3
  56. package/src/hooks/useProductsFood/queriesStore.js +120 -64
  57. package/src/hooks/useProductsFood/useEditProduct.js +42 -2
  58. package/src/hooks/useProductsFood/usetagsProducts.js +47 -43
  59. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +4 -4
  60. package/src/hooks/useSales/index.js +29 -19
  61. package/src/hooks/useSales/queries.js +140 -162
  62. package/src/hooks/useSales/useGetSale.js +3 -3
  63. package/src/hooks/useSaveAvailableProduct/index.js +1 -0
  64. package/src/hooks/useSetImageProducts/index.js +42 -13
  65. package/src/hooks/useSetImageProducts/queries.js +5 -0
  66. package/src/hooks/useStore/index.js +5 -1
  67. package/src/hooks/useStore/queries.js +71 -72
  68. package/src/hooks/useTagProducts/index.ts +3 -0
  69. package/src/hooks/useTagProducts/useDeleteOneTag.ts +106 -0
  70. package/src/hooks/useTagProducts/useGetAllTags.ts +68 -0
  71. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +156 -0
  72. package/src/hooks/useUpdateDashboardComponent/index.ts +91 -0
  73. package/src/hooks/useUpdateExistingOrders/index.js +3 -9
  74. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +25 -3
  75. package/src/hooks/useUpdateMultipleExtProduct/index.js +33 -0
  76. package/src/hooks/useUpdateMultipleExtProduct/queries.js +33 -0
  77. package/src/hooks/useUploadProducts/index.js +0 -1
  78. package/src/hooks/useUser/queries.js +0 -1
  79. package/src/utils/index.js +97 -5
  80. package/tsconfig.json +5 -0
  81. package/src/hooks/useUpdateMultipleExtProductFoods/index.js +0 -21
  82. package/src/hooks/useUpdateMultipleExtProductFoods/queries.js +0 -19
@@ -94,52 +94,54 @@ export const GET_ALL_SALES_STATISTICS = gql`
94
94
  `
95
95
 
96
96
  export const GET_ONE_SALES = gql`
97
- query getOnePedidoStore($pCodeRef: String) {
98
- getOnePedidoStore(pCodeRef: $pCodeRef) {
99
- pdpId
100
- pCodeRef
101
- idStore
102
- pPDate
103
- channel
104
- pSState
105
- pDatCre
106
- pDatMod
107
- pPRecoger
108
- payMethodPState
109
- pdpId
110
- totalProductsPrice
111
- locationUser
112
- getAllPedidoStore {
97
+ query getOneSalesStore($pCodeRef: String) {
98
+ getOneSalesStore(pCodeRef: $pCodeRef) {
99
+ pdpId
100
+ idStore
101
+ pCodeRef
102
+ payMethodPState
103
+ pPRecoger
104
+ totalProductsPrice
105
+ pSState
106
+ pDatCre
107
+ locationUser
108
+ pDatMod
109
+ getAllPedidoStore{
113
110
  pdpId
111
+ pId
114
112
  idStore
115
- pCodeRef
116
113
  ShoppingCard
114
+ pCodeRef
115
+ pPStateP
116
+ payMethodPState
117
+ pPRecoger
118
+ pDatCre
119
+ pDatMod
117
120
  getAllShoppingCard {
118
121
  ShoppingCard
119
- cantProducts
120
- subProductsId
121
122
  comments
123
+ cantProducts
122
124
  pId
123
- productFood {
124
- pId
125
- carProId
126
- colorId
127
- idStore
128
- pName
129
- ProPrice
130
- ProDescuento
131
- ProDescription
132
- ValueDelivery
133
- ProImage
134
- ProStar
135
- pState
136
- pDatCre
137
- pDatMod
138
- }
125
+ productFood{
126
+ pId
127
+ carProId
128
+ colorId
129
+ idStore
130
+ pName
131
+ ProPrice
132
+ ProDescuento
133
+ ProDescription
134
+ ValueDelivery
135
+ ProImage
136
+ ProStar
137
+ pState
138
+ pDatCre
139
+ pDatMod
139
140
  }
140
141
  }
141
142
  }
142
143
  }
144
+ }
143
145
  `
144
146
 
145
147
  export const CREATE_CLIENTS = gql`
@@ -252,149 +254,125 @@ export const CREATE_SHOPPING_CARD = gql`
252
254
  }
253
255
  `
254
256
  export const GET_ONE_SALE = gql`
255
- query getOnePedidoStore($pCodeRef: String) {
256
- getOnePedidoStore(pCodeRef: $pCodeRef) {
257
- pdpId
258
- pCodeRef
259
- idStore
260
- pPDate
257
+ query getOneSalesStore($pCodeRef: String) {
258
+ getOneSalesStore(pCodeRef: $pCodeRef) {
259
+ message
260
+ message
261
+ errors {
262
+ message
263
+ path
264
+ type
265
+ context {
266
+ key
267
+ label
268
+ limit
269
+ value
270
+ __typename
271
+ }
272
+ }
273
+ data {
274
+ change
261
275
  channel
262
- pSState
263
- pDatCre
264
- pDatMod
265
- pPRecoger
266
- payMethodPState
276
+ id
277
+ locationUser
278
+ pCodeRef
267
279
  pdpId
280
+ ppState
281
+ ppState
282
+ shoppingCartRefCode
283
+ pSState
268
284
  totalProductsPrice
269
- locationUser
270
- getAllPedidoStore {
271
- pdpId
272
- idStore
273
- pCodeRef
274
- ShoppingCard
275
- getAllShoppingCard {
276
- ShoppingCard
277
- cantProducts
278
- priceProduct
279
- refCodePid
280
- subProductsId
281
- comments
282
- pId
283
- salesExtProductFoodOptional {
284
- pId
285
- opExPid
286
- OptionalProName
287
- state
288
- code
289
- required
290
- numbersOptionalOnly
291
- pDatCre
292
- pDatMod
293
- saleExtProductFoodsSubOptionalAll {
294
- pId
295
- opExPid
296
- idStore
297
- opSubExPid
298
- OptionalSubProName
299
- exCodeOptionExtra
300
- exCode
301
- state
302
- pDatCre
303
- pDatMod
304
- }
305
- }
306
- ExtProductFoodsAll {
307
- pId
308
- exPid
309
- exState
310
- extraName
311
- extraPrice
312
- newExtraPrice
313
- quantity
314
- state
315
- pDatCre
316
- pDatMod
317
- }
318
- productFood {
319
- pId
320
- carProId
321
- colorId
322
- idStore
323
- pName
324
- ProPrice
325
- ProDescuento
326
- ProDescription
327
- ValueDelivery
328
- ProImage
329
- ProStar
330
- pState
331
- pDatCre
332
- pDatMod
333
- }
334
- }
335
- }
285
+ unidProducts
286
+ updatedAt
287
+ createdAt
288
+ __typename
336
289
  }
337
290
  }
291
+ }
338
292
  `
339
293
 
340
294
  export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
341
- mutation registerSalesStore(
342
- $input: [IShoppingCard]
343
- $id: ID
344
- $idStore: ID
345
- $pCodeRef: String
346
- $discount: Int
347
- $change: Float
348
- $tableId: ID
349
- $valueDelivery: Float
350
- $payMethodPState: Int
351
- $pickUp: Int
352
- $totalProductsPrice: Float
353
- $idSubArray: IID_SUB_ITEMS
295
+ mutation registerSalesStore(
296
+ $input: [IShoppingCart]
297
+ $id: ID
298
+ $tableId: ID
299
+ $discount: Int
300
+ $idStore: ID
301
+ $pCodeRef: String
302
+ $change: Float
303
+ $shoppingCartRefCode: String
304
+ $payMethodPState: Int
305
+ $pickUp: Int
306
+ $totalProductsPrice: Float
307
+ $valueDelivery: Float
308
+ $idSubArray: IID_SUB_ITEMS
309
+ ) {
310
+ registerSalesStore(
311
+ input: $input
312
+ id: $id
313
+ tableId: $tableId
314
+ discount: $discount
315
+ shoppingCartRefCode: $shoppingCartRefCode
316
+ idStore: $idStore
317
+ pCodeRef: $pCodeRef
318
+ change: $change
319
+
320
+ payMethodPState: $payMethodPState
321
+ pickUp: $pickUp
322
+ totalProductsPrice: $totalProductsPrice
323
+ valueDelivery: $valueDelivery
324
+ idSubArray: $idSubArray
354
325
  ) {
355
- registerSalesStore(
356
- input: $input
357
- id: $id
358
- idStore: $idStore
359
- pCodeRef: $pCodeRef
360
- change: $change
361
- tableId: $tableId
362
- discount: $discount
363
- valueDelivery: $valueDelivery
364
- payMethodPState: $payMethodPState
365
- pickUp: $pickUp
366
- totalProductsPrice: $totalProductsPrice
367
- idSubArray: $idSubArray
368
- ) {
369
- ShoppingCard {
370
- ShoppingCard
371
- id
372
- pId
373
- subProductsId
374
- ShoppingCardRefCode
375
- uuid
376
- discountCardProduct
377
- idUser
378
- cName
326
+ success
327
+ message
328
+ errors {
329
+ path
330
+ message
331
+ type
332
+ context {
333
+ limit
334
+ value
335
+ label
336
+ key
337
+ __typename
338
+ }
339
+ }
340
+ data {
341
+ pCodeRef
342
+ idStore
343
+ id
344
+ channel
345
+ payMethodPState
346
+ pSState
347
+ createdAt
348
+ updatedAt
349
+ unidProducts
350
+ totalProductsPrice
351
+ getOneStore {
379
352
  idStore
380
- cState
381
- cDatCre
382
- cDatMod
383
- csDescription
384
- cantProducts
385
- comments
353
+ cId
354
+ dId
355
+ catStore
356
+ scheduleOpenAll
357
+ dailyGoal
358
+ deliveryTimeMinutes
386
359
  }
387
- Response {
388
- success
389
- message
360
+ getUser {
361
+ id
362
+ name
363
+ email
364
+ createdAt
365
+ updatedAt
366
+ __typename
390
367
  }
391
368
  }
392
369
  }
370
+ }
393
371
  `
394
372
 
395
- export const GET_ALL_PEDIDOS = gql`
396
- query getAllPedidoStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int, $statusOrder: Int) {
397
- getAllPedidoStoreFinal(idStore: $idStore, search: $search, min: $min, max: $max, statusOrder: $statusOrder) {
373
+ export const GET_ALL_ORDER = gql`
374
+ query getAllOrderStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int, $statusOrder: Int) {
375
+ getAllOrderStoreFinal(idStore: $idStore, search: $search, min: $min, max: $max, statusOrder: $statusOrder) {
398
376
  pdpId
399
377
  idStore
400
378
  pCodeRef
@@ -2,12 +2,12 @@ import { useLazyQuery } from '@apollo/client'
2
2
  import { GET_ONE_SALE } from './queries'
3
3
 
4
4
  export const useGetSale = () => {
5
- const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
5
+ const [getOneSalesStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
6
6
  return {
7
- data: data?.getOnePedidoStore,
7
+ data: data?.getOneSalesStore,
8
8
  loading,
9
9
  error,
10
10
  called,
11
- getOnePedidoStore
11
+ getOneSalesStore
12
12
  }
13
13
  }
@@ -23,6 +23,7 @@ export const useSaveAvailableProduct = () => {
23
23
  handleDaySelection,
24
24
  handleCleanSelectedDays,
25
25
  selectedDays,
26
+ setSelectedDays,
26
27
  days,
27
28
  Loading: loading,
28
29
  registerAvailableProduct
@@ -1,28 +1,57 @@
1
- import { useMutation } from '@apollo/client'
1
+ import { useMutation, useApolloClient } from '@apollo/client'
2
2
  import { UPDATE_IMAGE_PRODUCT_FOOD } from './queries'
3
+ import { GET_ONE_PRODUCTS_FOOD } from '../useProductsFood/queriesStore'
3
4
 
5
+ /**
6
+ * Hook to update product image and sync Apollo cache.
7
+ *
8
+ * @returns {[Function, Object]} mutation function and its state
9
+ */
4
10
  export const useSetImageProducts = () => {
11
+ const client = useApolloClient()
12
+
5
13
  const [setImageProducts, { data, loading, error }] = useMutation(UPDATE_IMAGE_PRODUCT_FOOD)
6
14
 
15
+ /**
16
+ * Updates product image and manually updates Apollo cache.
17
+ *
18
+ * @param {Object} variables - Requires pId and image
19
+ * @returns {Promise<any>}
20
+ */
7
21
  const updateImageProducts = async (variables) => {
22
+ const { pId, image } = variables
23
+
24
+ if (!pId || !image) throw new Error('Missing pId or image')
25
+
26
+ const response = await setImageProducts({
27
+ variables: { input: { pId, image } }
28
+ })
29
+ const { ProImage } = response?.data?.setImageProducts?.data ?? {}
8
30
  try {
9
- const response = await setImageProducts({
10
- variables: {
11
- input: {
12
- ...variables
31
+ const existing = client.readQuery({
32
+ query: GET_ONE_PRODUCTS_FOOD,
33
+ variables: { pId }
34
+ })
35
+
36
+ if (!existing?.productFoodsOne) return response
37
+
38
+ // 📝 Escribir de nuevo el producto con la imagen actualizada
39
+ client.writeQuery({
40
+ query: GET_ONE_PRODUCTS_FOOD,
41
+ variables: { pId },
42
+ data: {
43
+ productFoodsOne: {
44
+ ...existing.productFoodsOne,
45
+ ProImage
13
46
  }
14
47
  }
15
48
  })
16
- return response
17
49
  } catch (err) {
18
- console.error('Error updating image products:', err)
19
- throw err
50
+ console.warn('⚠️ Error updating cache for GET_ONE_PRODUCTS_FOOD:', err)
20
51
  }
52
+
53
+ return response
21
54
  }
22
55
 
23
- return [updateImageProducts, {
24
- data,
25
- loading,
26
- error
27
- }]
56
+ return [updateImageProducts, { data, loading, error }]
28
57
  }
@@ -5,6 +5,11 @@ export const UPDATE_IMAGE_PRODUCT_FOOD = gql`
5
5
  setImageProducts(input: $input) {
6
6
  success
7
7
  message
8
+ data {
9
+ pId
10
+ ProImage
11
+ __typename
12
+ }
8
13
  errors {
9
14
  message
10
15
  }
@@ -4,7 +4,11 @@ import { GET_ONE_STORE, GET_ONE_STORE_BY_ID } from './queries' // Reemplaza con
4
4
  import { errorHandler } from '../../config/client'
5
5
  import { useLogout } from '../useLogout'
6
6
 
7
- export const useStore = ({ isClient = false, idStore = null, callback = () => {} } = {}) => {
7
+ export const useStore = ({
8
+ isClient = false,
9
+ idStore = null,
10
+ callback = () => { }
11
+ } = {}) => {
8
12
  const client = useApolloClient()
9
13
  const [onClickLogout, { loading: load }] = useLogout()
10
14
 
@@ -11,68 +11,68 @@ mutation newRegisterStore($input: IStore){
11
11
  `
12
12
 
13
13
  export const GET_ONE_STORE = gql`
14
- query getStore($id: ID, $idStore: ID){
15
- getStore(id: $id, idStore: $idStore){
16
- cId
17
- id
18
- deliveryTimeMinutes
19
- scheduleOpenAll
20
- dId
21
- idStore
22
- ctId
23
- neighborhoodStore
24
- Viaprincipal
25
- catStore
26
- storeOwner
27
- storeName
28
- ImageName
29
- emailStore
30
- storePhone
31
- socialRaz
32
- Image
33
- banner
34
-
35
- documentIdentifier
36
- uPhoNum
37
- storeName
38
- ULocation
39
- upLat
40
- upLon
41
- uState
42
- siteWeb
43
- dailyGoal
44
- description
45
- createdAt
46
- secVia
47
- NitStore
48
- typeRegiments
49
- typeContribute
50
- addressStore
51
- pais {
52
- cId
53
- cName
54
- cCalCod
55
- cState
56
- cDatCre
57
- cDatMod
58
- }
59
- city {
60
- ctId
61
- dId
62
- cName
63
- cState
64
- cDatCre
65
- cDatMod
66
- }
67
- department {
68
- dId
69
- cId
70
- dName
71
- dState
72
- dDatCre
73
- dDatMod
74
- }
75
- getStoreSchedules {
14
+ query getStore($id: ID, $idStore: ID) {
15
+ getStore(id: $id, idStore: $idStore) {
16
+ cId
17
+ id
18
+ deliveryTimeMinutes
19
+ scheduleOpenAll
20
+ dId
21
+ idStore
22
+ ctId
23
+ neighborhoodStore
24
+ Viaprincipal
25
+ catStore
26
+ storeOwner
27
+ storeName
28
+ ImageName
29
+ emailStore
30
+ storePhone
31
+ socialRaz
32
+ Image
33
+ banner
34
+
35
+ documentIdentifier
36
+ uPhoNum
37
+ storeName
38
+ ULocation
39
+ upLat
40
+ upLon
41
+ uState
42
+ siteWeb
43
+ dailyGoal
44
+ description
45
+ createdAt
46
+ secVia
47
+ NitStore
48
+ typeRegiments
49
+ typeContribute
50
+ addressStore
51
+ pais {
52
+ cId
53
+ cName
54
+ cCalCod
55
+ cState
56
+ cDatCre
57
+ cDatMod
58
+ }
59
+ city {
60
+ ctId
61
+ dId
62
+ cName
63
+ cState
64
+ cDatCre
65
+ cDatMod
66
+ }
67
+ department {
68
+ dId
69
+ cId
70
+ dName
71
+ dState
72
+ dDatCre
73
+ dDatMod
74
+ }
75
+ getStoreSchedules {
76
76
  idStore
77
77
  schId
78
78
  id
@@ -80,17 +80,16 @@ pais {
80
80
  schHoSta
81
81
  schHoEnd
82
82
  schState
83
+ }
84
+ cateStore {
85
+ catStore
86
+ cName
87
+ cState
88
+ createdAt
89
+ updatedAt
90
+ csDescription
91
+ }
83
92
  }
84
- cateStore {
85
- catStore
86
- cName
87
- cState
88
- cDatCre
89
- cDatMod
90
- csDescription
91
-
92
- }
93
- }
94
93
  }
95
94
  `
96
95
  export const GET_ONE_STORE_BY_ID = gql`
@@ -0,0 +1,3 @@
1
+ export * from './useRegisterMultipleTags'
2
+ export * from './useGetAllTags'
3
+ export * from './useDeleteOneTag'