npm-pkg-hook 1.11.3 → 1.11.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.
Files changed (81) hide show
  1. package/.env +5 -1
  2. package/package.json +1 -1
  3. package/src/config/content/en.json +5 -0
  4. package/src/config/content/es.json +5 -0
  5. package/src/config/content/index.js +16 -0
  6. package/src/hooks/index.js +6 -0
  7. package/src/hooks/newStoreOrderSubscription/index.js +1 -12
  8. package/src/hooks/updateExtProductFoodsOptional/index.js +2 -2
  9. package/src/hooks/useCatWithProduct/queries.js +50 -24
  10. package/src/hooks/useCategoriesProduct/index.js +1 -0
  11. package/src/hooks/useCategoriesProduct/queries.js +2 -2
  12. package/src/hooks/useCategoryInStore/queries.js +2 -2
  13. package/src/hooks/useClients/queries.js +72 -23
  14. package/src/hooks/useCreateProduct/helpers/index.js +2 -2
  15. package/src/hooks/useCreateProduct/index.js +45 -46
  16. package/src/hooks/useDessert/index.js +20 -3
  17. package/src/hooks/useDessertWithPrice/helpers/index.js +2 -2
  18. package/src/hooks/useDessertWithPrice/index.js +70 -60
  19. package/src/hooks/useDessertWithPrice/queries.js +2 -2
  20. package/src/hooks/useDevices/queries.js +16 -7
  21. package/src/hooks/useDevices/useGetDevices.js +12 -19
  22. package/src/hooks/useDevices/useRegisterDevices.js +3 -3
  23. package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +21 -0
  24. package/src/hooks/useDownloadReports/index.ts +2 -0
  25. package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +103 -0
  26. package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +115 -0
  27. package/src/hooks/useEditCategory/index.js +10 -10
  28. package/src/hooks/useFormTools/index.js +2 -1
  29. package/src/hooks/useFormatDate/index.js +56 -3
  30. package/src/hooks/useGetStoreCookie/index.js +1 -1
  31. package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +130 -0
  32. package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +53 -0
  33. package/src/hooks/useImageUploaderProduct/helper/index.ts +5 -0
  34. package/src/hooks/useImageUploaderProduct/index.ts +292 -0
  35. package/src/hooks/useImagesStore/index.js +100 -58
  36. package/src/hooks/useImagesStore/queries.js +2 -2
  37. package/src/hooks/useImagesStore/utils/index.js +4 -0
  38. package/src/hooks/useInventory/queries.js +1 -1
  39. package/src/hooks/useLocationManager/index.js +3 -1
  40. package/src/hooks/useLogout/helpers/fetchData.js +1 -1
  41. package/src/hooks/useLogout/helpers/logger.js +8 -8
  42. package/src/hooks/useLogout/index.js +6 -4
  43. package/src/hooks/useManageNewOrder/index.js +3 -3
  44. package/src/hooks/useManageQueryParams/index.js +28 -28
  45. package/src/hooks/useMobile/index.js +38 -8
  46. package/src/hooks/useOrderStatusTypes/index.ts +2 -0
  47. package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +52 -0
  48. package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +97 -0
  49. package/src/hooks/useOrders/index.js +2 -74
  50. package/src/hooks/useOrders/queries.js +31 -195
  51. package/src/hooks/useOrders/useChangeOrderState/index.ts +125 -0
  52. package/src/hooks/useOrders/useOrdersFromStore/index.ts +83 -0
  53. package/src/hooks/usePortFetcher/index.ts +33 -0
  54. package/src/hooks/useProductsFood/index.js +3 -3
  55. package/src/hooks/useProductsFood/queriesStore.js +120 -64
  56. package/src/hooks/useProductsFood/useEditProduct.js +42 -2
  57. package/src/hooks/useProductsFood/usetagsProducts.js +47 -43
  58. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +4 -4
  59. package/src/hooks/useSales/index.js +29 -19
  60. package/src/hooks/useSales/queries.js +140 -162
  61. package/src/hooks/useSales/useGetSale.js +3 -3
  62. package/src/hooks/useSaveAvailableProduct/index.js +1 -0
  63. package/src/hooks/useSetImageProducts/index.js +42 -13
  64. package/src/hooks/useSetImageProducts/queries.js +5 -0
  65. package/src/hooks/useStore/index.js +5 -1
  66. package/src/hooks/useStore/queries.js +71 -72
  67. package/src/hooks/useTagProducts/index.ts +3 -0
  68. package/src/hooks/useTagProducts/useDeleteOneTag.ts +106 -0
  69. package/src/hooks/useTagProducts/useGetAllTags.ts +68 -0
  70. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +156 -0
  71. package/src/hooks/useUpdateDashboardComponent/index.ts +91 -0
  72. package/src/hooks/useUpdateExistingOrders/index.js +3 -9
  73. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +25 -3
  74. package/src/hooks/useUpdateMultipleExtProduct/index.js +33 -0
  75. package/src/hooks/useUpdateMultipleExtProduct/queries.js +33 -0
  76. package/src/hooks/useUploadProducts/index.js +0 -1
  77. package/src/hooks/useUser/queries.js +0 -1
  78. package/src/utils/index.js +97 -5
  79. package/tsconfig.json +5 -0
  80. package/src/hooks/useUpdateMultipleExtProductFoods/index.js +0 -21
  81. package/src/hooks/useUpdateMultipleExtProductFoods/queries.js +0 -19
@@ -76,39 +76,39 @@ export const GET_ALL_EMPLOYEE_STORE = gql`
76
76
  `
77
77
 
78
78
  export const GET_ALL_PRODUCT_STORE = gql`
79
- query productFoodsAll(
80
- $search: String
81
- $min: Int
82
- $max: Int
83
- $gender: [String]
84
- $pState: Int
85
- $desc: [String]
86
- $categories: [ID]
87
- $fromDate: DateTime
88
- $toDate: DateTime
89
- $page: Int
79
+ query productFoodsAll(
80
+ $search: String
81
+ $min: Int
82
+ $max: Int
83
+ $gender: [String]
84
+ $pState: Int
85
+ $desc: [String]
86
+ $categories: [ID]
87
+ $fromDate: DateTime
88
+ $toDate: DateTime
89
+ $page: Int
90
+ ) {
91
+ productFoodsAll(
92
+ search: $search
93
+ min: $min
94
+ max: $max
95
+ gender: $gender
96
+ desc: $desc
97
+ pState: $pState
98
+ categories: $categories
99
+ toDate: $toDate
100
+ fromDate: $fromDate
101
+ page: $page
90
102
  ) {
91
- productFoodsAll(
92
- search: $search
93
- min: $min
94
- max: $max
95
- gender: $gender
96
- desc: $desc
97
- pState: $pState
98
- categories: $categories
99
- toDate: $toDate
100
- fromDate: $fromDate
101
- page: $page
102
- ) {
103
- success
104
- message
105
- pagination {
103
+ success
104
+ message
105
+ pagination {
106
106
  totalRecords
107
107
  totalPages
108
108
  currentPage
109
109
  __typename
110
110
  }
111
- data {
111
+ data {
112
112
  pId
113
113
  sizeId #Talla
114
114
  colorId #Color
@@ -122,7 +122,7 @@ export const GET_ALL_PRODUCT_STORE = gql`
122
122
  fId #Características
123
123
  pName
124
124
  getOneTags {
125
- tPsId
125
+ tgId
126
126
  idUser
127
127
  idStore
128
128
  pId
@@ -145,8 +145,8 @@ export const GET_ALL_PRODUCT_STORE = gql`
145
145
  ProWeight
146
146
  ProQuantity
147
147
  ProOutstanding
148
- pDatCre
149
- pDatMod
148
+ createdAt
149
+ updatedAt
150
150
  ProDelivery
151
151
  ProVoltaje
152
152
  pState
@@ -160,8 +160,8 @@ export const GET_ALL_PRODUCT_STORE = gql`
160
160
  aName
161
161
  }
162
162
  }
163
- }
164
163
  }
164
+ }
165
165
  `
166
166
  export const GET_ALL_RATING_START_STORE = gql`
167
167
  query getAllRatingStar($idStore: ID) {
@@ -222,10 +222,23 @@ export const GET_All_RATING_STORE = gql`
222
222
  }
223
223
  `
224
224
  export const CREATE_LOGO = gql`
225
- mutation setALogoStore($logo: Upload, $idStore: ID) {
226
- setALogoStore(logo: $logo, idStore: $idStore) {
225
+ mutation registerLogo($logo: Upload, $idStore: ID) {
226
+ registerLogo(logo: $logo, idStore: $idStore) {
227
227
  success
228
- message
228
+ message
229
+ data
230
+ errors {
231
+ path
232
+ message
233
+ type
234
+ context {
235
+ limit
236
+ value
237
+ label
238
+ key
239
+ __typename
240
+ }
241
+ }
229
242
  }
230
243
  }
231
244
  `
@@ -260,14 +273,14 @@ export const GET_ONE_BANNER_STORE = gql`
260
273
  }
261
274
  `
262
275
  export const DELETE_ONE_BANNER_STORE = gql`
263
- mutation DeleteOneBanner(
276
+ mutation deleteOneBanner(
264
277
  $bnState: Int
265
278
  $idStore: ID
266
279
  $bnId: ID
267
280
  $bnImage: String
268
281
  $bnImageFileName: String
269
282
  ) {
270
- DeleteOneBanner(
283
+ deleteOneBanner(
271
284
  bnState: $bnState
272
285
  idStore: $idStore
273
286
  bnId: $bnId
@@ -396,8 +409,8 @@ export const UPDATE_EXTRAS_PRODUCT_FOOD = gql`
396
409
  `
397
410
  // EXTRA PRODUCTS
398
411
  export const UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
399
- mutation updateExtProductFoodsOptional($input: InputExtProductFoodOptional) {
400
- updateExtProductFoodsOptional(input: $input) {
412
+ mutation updateExtProductOptional($input: InputExtProductFoodOptional) {
413
+ updateExtProductOptional(input: $input) {
401
414
  success,
402
415
  message
403
416
  }
@@ -422,9 +435,9 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
422
435
  state
423
436
  code
424
437
  numbersOptionalOnly
425
- pDatCre
438
+ createdAt
426
439
  required
427
- pDatMod
440
+ updatedAt
428
441
  ExtProductFoodsSubOptionalAll {
429
442
  pId
430
443
  opExPid
@@ -434,17 +447,20 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
434
447
  exCodeOptionExtra
435
448
  exCode
436
449
  state
437
- pDatCre
438
- pDatMod
450
+ createdAt
451
+ updatedAt
439
452
  }
440
453
  }
441
454
  }
442
455
  `
443
456
  export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
444
- mutation updateExtProductFoodsSubOptional(
445
- $input: InputExtProductFoodSubOptional
446
- ) {
447
- updateExtProductFoodsSubOptional(input: $input) {
457
+ mutation updateExtProductSubOptional(
458
+ $input: InputExtProductFoodSubOptional
459
+ ) {
460
+ updateExtProductSubOptional(input: $input) {
461
+ success
462
+ message
463
+ data {
448
464
  pId
449
465
  opExPid
450
466
  idStore
@@ -453,10 +469,23 @@ export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
453
469
  exCodeOptionExtra
454
470
  exCode
455
471
  state
456
- pDatCre
457
- pDatMod
472
+ createdAt
473
+ updatedAt
474
+ }
475
+ errors {
476
+ path
477
+ message
478
+ type
479
+ context {
480
+ limit
481
+ value
482
+ label
483
+ key
484
+ __typename
485
+ }
458
486
  }
459
487
  }
488
+ }
460
489
  `
461
490
 
462
491
  export const DELETE_ONE_PRODUCT = gql`
@@ -564,6 +593,17 @@ export const EDIT_PRODUCT = gql`
564
593
  editProductFoods(input: $input) {
565
594
  success
566
595
  message
596
+ errors {
597
+ path
598
+ message
599
+ type
600
+ context {
601
+ limit
602
+ value
603
+ label
604
+ key
605
+ }
606
+ }
567
607
  }
568
608
  }
569
609
  `
@@ -592,6 +632,7 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
592
632
  ctId
593
633
  tpId
594
634
  fId
635
+ tgId
595
636
  pName
596
637
  ProPrice
597
638
  ProBarCode
@@ -613,10 +654,10 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
613
654
  ProVoltaje
614
655
  pState
615
656
  sTateLogistic
616
- pDatCre
617
- pDatMod
657
+ createdAt
658
+ updatedAt
618
659
  getOneTags {
619
- tPsId
660
+ tgId
620
661
  idUser
621
662
  idStore
622
663
  pId
@@ -628,8 +669,8 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
628
669
  idStore
629
670
  pId
630
671
  dayAvailable
631
- pDatCre
632
- pDatMod
672
+ createdAt
673
+ updatedAt
633
674
  }
634
675
  ExtProductFoodsAll {
635
676
  pId
@@ -638,8 +679,8 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
638
679
  extraName
639
680
  extraPrice
640
681
  state
641
- pDatCre
642
- pDatMod
682
+ createdAt
683
+ updatedAt
643
684
  }
644
685
  getStore {
645
686
  idStore
@@ -746,8 +787,8 @@ export const DELETE_ONE_CAT_PRODUCTS_FINAL = gql`
746
787
  }
747
788
  `
748
789
  export const DELETE_EXTRA_PRODUCTS = gql`
749
- mutation deleteextraproductfoods($id: ID, $state: Int) {
750
- deleteextraproductfoods(id: $id, state: $state) {
790
+ mutation deleteExtraProduct($id: ID, $state: Int) {
791
+ deleteExtraProduct(id: $id, state: $state) {
751
792
  success
752
793
  message
753
794
  }
@@ -808,8 +849,8 @@ export const GET_ULTIMATE_CATEGORY_PRODUCTS = gql`
808
849
  ProDescription
809
850
  ProImage
810
851
  pState
811
- pDatCre
812
- pDatMod
852
+ createdAt
853
+ updatedAt
813
854
  }
814
855
  }
815
856
  `
@@ -822,8 +863,8 @@ export const GET_ALL_EXTRA_PRODUCT = gql`
822
863
  extraName
823
864
  extraPrice
824
865
  state
825
- pDatCre
826
- pDatMod
866
+ createdAt
867
+ updatedAt
827
868
  }
828
869
  }
829
870
  `
@@ -887,8 +928,8 @@ export const GET_ALL_CATEGORIES_WITH_PRODUCT = gql`
887
928
  ProVoltaje
888
929
  pState
889
930
  sTateLogistic
890
- pDatCre
891
- pDatMod
931
+ createdAt
932
+ updatedAt
892
933
  }
893
934
  }
894
935
  }
@@ -897,12 +938,27 @@ export const GET_ALL_CATEGORIES_WITH_PRODUCT = gql`
897
938
  export const REGISTER_TAGS_PRODUCT = gql`
898
939
  mutation registerTag($input: ITag) {
899
940
  registerTag(input: $input) {
900
- tPsId
941
+ data {
942
+ tgId
901
943
  idUser
902
944
  idStore
903
945
  pId
904
946
  nameTag
905
947
  aName
948
+ }
949
+ success
950
+ message
951
+ errors {
952
+ path
953
+ message
954
+ type
955
+ context {
956
+ limit
957
+ value
958
+ label
959
+ key
960
+ }
961
+ }
906
962
  }
907
963
  }
908
964
  `
@@ -1,8 +1,48 @@
1
1
  import { useMutation } from '@apollo/client'
2
2
  import { EDIT_PRODUCT } from './queriesStore'
3
3
 
4
- export const useEditProduct = () => {
5
- const [editProductFoods, { loading, error }] = useMutation(EDIT_PRODUCT)
4
+ export const useEditProduct = ({
5
+ sendNotification = () => {
6
+ return null
7
+ }
8
+ } = {}) => {
9
+ const [editProductFoods, { loading, error }] = useMutation(EDIT_PRODUCT, {
10
+ onCompleted: (data) => {
11
+ const { editProductFoods } = data
12
+ const {
13
+ success,
14
+ message,
15
+ errors
16
+ } = editProductFoods || {
17
+ success: false,
18
+ message: '',
19
+ errors: []
20
+ }
21
+ if (errors && errors.length > 0) {
22
+ for (const error of errors) {
23
+ sendNotification({
24
+ title: 'Error',
25
+ description: `${error.message}`,
26
+ backgroundColor: 'error'
27
+ })
28
+ }
29
+ }
30
+ if (success) {
31
+ sendNotification({
32
+ title: 'Error',
33
+ description: `${message}`,
34
+ backgroundColor: 'error'
35
+ })
36
+ }
37
+ },
38
+ onError: (error) => {
39
+ sendNotification({
40
+ title: 'Error',
41
+ description: error.message,
42
+ backgroundColor: 'error'
43
+ })
44
+ }
45
+ })
6
46
 
7
47
  return [editProductFoods, { loading, error }]
8
48
  }
@@ -1,51 +1,15 @@
1
1
  import { useState } from 'react'
2
2
  import { useMutation } from '@apollo/client'
3
3
  import { REGISTER_TAGS_PRODUCT } from './queriesStore'
4
+ import { useDeleteOneTag, useGetAllTags } from '../useTagProducts'
4
5
 
5
- export const useTagsProducts = () => {
6
+ export const useTagsProducts = ({
7
+ sendNotification = () => { }
8
+ } = {}) => {
6
9
  const [registerTag] = useMutation(REGISTER_TAGS_PRODUCT)
7
- const data = [
8
- {
9
- id: 1,
10
- tag: 'Bebida fría'
11
- },
12
- {
13
- id: 2,
14
- tag: 'Bebida caliente'
15
- },
16
- {
17
- id: 3,
18
- tag: 'Bebida alcohólica'
19
- },
20
- {
21
- id: 4,
22
- tag: 'Bebida sin alcohol'
23
- },
24
- {
25
- id: 5,
26
- tag: 'Entrante'
27
- },
28
- {
29
- id: 6,
30
- tag: 'Plato principal'
31
- },
32
- {
33
- id: 7,
34
- tag: 'Postre'
35
- },
36
- {
37
- id: 8,
38
- tag: 'Sopa'
39
- },
40
- {
41
- id: 9,
42
- tag: 'Ensalada'
43
- },
44
- {
45
- id: 10,
46
- tag: 'Mariscos'
47
- }
48
- ]
10
+ const [handleDeleteTag, { loading }] = useDeleteOneTag()
11
+ const { tags: listTags } = useGetAllTags()
12
+ const [newTags, setNewTags] = useState([])
49
13
 
50
14
  const [tags, setTags] = useState({
51
15
  id: '',
@@ -64,6 +28,36 @@ export const useTagsProducts = () => {
64
28
  tag
65
29
  })
66
30
  }
31
+
32
+ const handleRemoveTag = async (tag) => {
33
+ try {
34
+ if (loading) return
35
+ const { id: tgId, tag: nameTag } = tag ?? {
36
+ tgId: null,
37
+ nameTag: null
38
+ }
39
+ const response = await handleDeleteTag({ tgId, nameTag })
40
+ const {
41
+ success = false,
42
+ message = '',
43
+ data
44
+ } = response ?? {}
45
+
46
+ const name = data?.nameTag ?? ''
47
+ return sendNotification({
48
+ title: name ?? 'error',
49
+ description: message,
50
+ backgroundColor: success ? 'success' : 'error'
51
+ })
52
+ } catch (e) {
53
+ sendNotification({
54
+ title: 'Error',
55
+ description: 'error',
56
+ backgroundColor: 'error'
57
+ })
58
+ }
59
+ }
60
+
67
61
  const handleRegister = tag => {
68
62
  const {
69
63
  pId,
@@ -83,12 +77,22 @@ export const useTagsProducts = () => {
83
77
  }
84
78
  }).catch(err => { return console.log({ message: `${err}`, duration: 7000 }) })
85
79
  }
80
+ const data = listTags.map((tag) => {
81
+ return {
82
+ id: tag?.tgId ?? '',
83
+ tag: String(tag?.nameTag ?? '')
84
+ }
85
+ })
86
+
86
87
  return {
87
88
  tags,
88
89
  error: false,
89
90
  data,
90
91
  loading: false,
92
+ newTags: newTags ?? [],
93
+ setNewTags,
91
94
  handleRegister,
95
+ handleRemoveTag,
92
96
  handleAddTag
93
97
  }
94
98
  }
@@ -28,9 +28,9 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
28
28
  state
29
29
  code
30
30
  numbersOptionalOnly
31
- pDatCre
31
+ createdAt
32
32
  required
33
- pDatMod
33
+ updatedAt
34
34
  ExtProductFoodsSubOptionalAll {
35
35
  pId
36
36
  opExPid
@@ -40,8 +40,8 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
40
40
  exCodeOptionExtra
41
41
  exCode
42
42
  state
43
- pDatCre
44
- pDatMod
43
+ createdAt
44
+ updatedAt
45
45
  }
46
46
  }
47
47
  }
@@ -112,8 +112,8 @@ export const useSales = ({
112
112
  CREATE_SHOPPING_CARD_TO_USER_STORE,
113
113
  {
114
114
  onCompleted: (data) => {
115
- const message = `${data?.registerSalesStore?.Response?.message}`
116
- const error = data?.registerSalesStore?.Response.success
115
+ const message = `${data?.registerSalesStore?.message}`
116
+ const error = data?.registerSalesStore?.success
117
117
  ? 'Éxito'
118
118
  : 'Error'
119
119
  sendNotification({
@@ -126,12 +126,12 @@ export const useSales = ({
126
126
  // @ts-ignore
127
127
  onClickLogout()
128
128
  }
129
- setOpenCurrentSale(data?.registerSalesStore?.Response.success)
129
+ setOpenCurrentSale(data?.registerSalesStore.success)
130
130
  },
131
131
  onError: (error) => {
132
132
  sendNotification({
133
133
  backgroundColor: 'error',
134
- title: error || 'Lo sentimos',
134
+ title: error ?? 'Lo sentimos',
135
135
  description: 'ha ocurrido un error'
136
136
  })
137
137
  }
@@ -795,7 +795,6 @@ export const useSales = ({
795
795
  sendAlertStock(stock)
796
796
  return state
797
797
  }
798
-
799
798
  const updatedProduct = {
800
799
  pId,
801
800
  pName,
@@ -954,6 +953,7 @@ export const useSales = ({
954
953
  }
955
954
  )
956
955
  const refCodePid = RandomCode(20)
956
+ const shoppingCartRefCode = RandomCode(36)
957
957
  return {
958
958
  pId: product?.pId,
959
959
  refCodePid,
@@ -1027,7 +1027,7 @@ export const useSales = ({
1027
1027
  }
1028
1028
  const totalProductsPrice = totalProductPrice
1029
1029
  const client = useApolloClient()
1030
- const { getOnePedidoStore } = useGetSale()
1030
+ const { getOneSalesStore } = useGetSale()
1031
1031
 
1032
1032
  const handleSubmit = () => {
1033
1033
  // @ts-ignore
@@ -1059,9 +1059,18 @@ export const useSales = ({
1059
1059
  tableId: null,
1060
1060
  cliId: null
1061
1061
  }
1062
+
1063
+ const shoppingCartRefCode = `REF-${RandomCode(36)}`
1064
+
1065
+ const input = finalArrayProduct.map((item) => {
1066
+ return {
1067
+ ...item,
1068
+ shoppingCartRefCode
1069
+ }
1070
+ })
1062
1071
  return registerSalesStore({
1063
1072
  variables: {
1064
- input: finalArrayProduct || [],
1073
+ input,
1065
1074
  id: values?.cliId,
1066
1075
  pCodeRef: code,
1067
1076
  tableId,
@@ -1069,7 +1078,8 @@ export const useSales = ({
1069
1078
  valueDelivery: convertInteger(valueDelivery),
1070
1079
  payMethodPState: data.payMethodPState,
1071
1080
  pickUp: 1,
1072
- discount: discount.discount || 0,
1081
+ shoppingCartRefCode,
1082
+ discount: discount.discount ?? 0,
1073
1083
  totalProductsPrice: convertInteger(totalProductsPrice) || 0
1074
1084
  },
1075
1085
  update (cache) {
@@ -1082,12 +1092,12 @@ export const useSales = ({
1082
1092
  })
1083
1093
  }
1084
1094
  })
1085
- .then((responseRegisterR) => {
1086
- if (responseRegisterR) {
1087
- const { data } = responseRegisterR || {}
1088
- const { registerSalesStore } = data || {}
1089
- const { Response } = registerSalesStore || {}
1090
- if (Response && Response.success === true) {
1095
+ .then((response) => {
1096
+ if (response) {
1097
+ const { data } = response
1098
+ const { registerSalesStore } = data ?? {}
1099
+ const { success } = registerSalesStore ?? {}
1100
+ if (success) {
1091
1101
  setPrint(false)
1092
1102
  client.query({
1093
1103
  query: GET_ALL_COUNT_SALES,
@@ -1099,13 +1109,13 @@ export const useSales = ({
1099
1109
  })
1100
1110
  setValues({})
1101
1111
  handleChange({ target: { name: 'tableId', value: '' } })
1102
- getOnePedidoStore({
1112
+ getOneSalesStore({
1103
1113
  variables: {
1104
1114
  pCodeRef: code || ''
1105
1115
  }
1106
1116
  }).then((responseSale) => {
1107
- if (responseSale?.data?.getOnePedidoStore) {
1108
- const currentSale = responseSale?.data?.getOnePedidoStore || {}
1117
+ if (responseSale?.data?.getOneSalesStore) {
1118
+ const currentSale = responseSale?.data?.getOneSalesStore || {}
1109
1119
  const inComingCodeRef = currentSale?.pCodeRef || null
1110
1120
  if (!inComingCodeRef) return
1111
1121
  client.cache.modify({
@@ -1198,7 +1208,7 @@ export const useSales = ({
1198
1208
  }
1199
1209
  const extProductFoodsSubOptionalAll =
1200
1210
  obj.ExtProductFoodsSubOptionalAll || []
1201
- const updateExtProductFoodsSubOptionalAll =
1211
+ const updateExtProductSubOptionalAll =
1202
1212
  extProductFoodsSubOptionalAll.map((subObj) => {
1203
1213
  const newItem =
1204
1214
  matchingArray.ExtProductFoodsSubOptionalAll.find(
@@ -1216,7 +1226,7 @@ export const useSales = ({
1216
1226
  return {
1217
1227
  ...obj,
1218
1228
  ExtProductFoodsSubOptionalAll:
1219
- updateExtProductFoodsSubOptionalAll
1229
+ updateExtProductSubOptionalAll
1220
1230
  }
1221
1231
  })
1222
1232
  .filter((obj) => obj)