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.
- package/.env +5 -1
- package/package.json +3 -2
- package/src/config/client/errors.js +1 -1
- package/src/config/content/en.json +5 -0
- package/src/config/content/es.json +5 -0
- package/src/config/content/index.js +16 -0
- package/src/hooks/index.js +6 -0
- package/src/hooks/newStoreOrderSubscription/index.js +1 -12
- package/src/hooks/updateExtProductFoodsOptional/index.js +2 -2
- package/src/hooks/useCatWithProduct/queries.js +50 -24
- package/src/hooks/useCategoriesProduct/index.js +1 -0
- package/src/hooks/useCategoriesProduct/queries.js +2 -2
- package/src/hooks/useCategoryInStore/queries.js +2 -2
- package/src/hooks/useClients/queries.js +72 -23
- package/src/hooks/useCreateProduct/helpers/index.js +2 -2
- package/src/hooks/useCreateProduct/index.js +45 -46
- package/src/hooks/useDessert/index.js +20 -3
- package/src/hooks/useDessertWithPrice/helpers/index.js +2 -2
- package/src/hooks/useDessertWithPrice/index.js +70 -60
- package/src/hooks/useDessertWithPrice/queries.js +2 -2
- package/src/hooks/useDevices/queries.js +16 -7
- package/src/hooks/useDevices/useGetDevices.js +12 -19
- package/src/hooks/useDevices/useRegisterDevices.js +3 -3
- package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +21 -0
- package/src/hooks/useDownloadReports/index.ts +2 -0
- package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +103 -0
- package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +115 -0
- package/src/hooks/useEditCategory/index.js +10 -10
- package/src/hooks/useFormTools/index.js +2 -1
- package/src/hooks/useFormatDate/index.js +56 -3
- package/src/hooks/useGetStoreCookie/index.js +1 -1
- package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +130 -0
- package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +53 -0
- package/src/hooks/useImageUploaderProduct/helper/index.ts +5 -0
- package/src/hooks/useImageUploaderProduct/index.ts +292 -0
- package/src/hooks/useImagesStore/index.js +100 -58
- package/src/hooks/useImagesStore/queries.js +2 -2
- package/src/hooks/useImagesStore/utils/index.js +4 -0
- package/src/hooks/useInventory/queries.js +1 -1
- package/src/hooks/useLocationManager/index.js +3 -1
- package/src/hooks/useLogout/helpers/fetchData.js +1 -1
- package/src/hooks/useLogout/helpers/logger.js +8 -8
- package/src/hooks/useLogout/index.js +6 -4
- package/src/hooks/useManageNewOrder/index.js +3 -3
- package/src/hooks/useManageQueryParams/index.js +28 -28
- package/src/hooks/useMobile/index.js +38 -8
- package/src/hooks/useOrderStatusTypes/index.ts +2 -0
- package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +52 -0
- package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +97 -0
- package/src/hooks/useOrders/index.js +2 -74
- package/src/hooks/useOrders/queries.js +31 -195
- package/src/hooks/useOrders/useChangeOrderState/index.ts +125 -0
- package/src/hooks/useOrders/useOrdersFromStore/index.ts +83 -0
- package/src/hooks/usePortFetcher/index.ts +33 -0
- package/src/hooks/useProductsFood/index.js +3 -3
- package/src/hooks/useProductsFood/queriesStore.js +120 -64
- package/src/hooks/useProductsFood/useEditProduct.js +42 -2
- package/src/hooks/useProductsFood/usetagsProducts.js +47 -43
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +4 -4
- package/src/hooks/useSales/index.js +29 -19
- package/src/hooks/useSales/queries.js +140 -162
- package/src/hooks/useSales/useGetSale.js +3 -3
- package/src/hooks/useSaveAvailableProduct/index.js +1 -0
- package/src/hooks/useSetImageProducts/index.js +42 -13
- package/src/hooks/useSetImageProducts/queries.js +5 -0
- package/src/hooks/useStore/index.js +5 -1
- package/src/hooks/useStore/queries.js +71 -72
- package/src/hooks/useTagProducts/index.ts +3 -0
- package/src/hooks/useTagProducts/useDeleteOneTag.ts +106 -0
- package/src/hooks/useTagProducts/useGetAllTags.ts +68 -0
- package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +156 -0
- package/src/hooks/useUpdateDashboardComponent/index.ts +91 -0
- package/src/hooks/useUpdateExistingOrders/index.js +3 -9
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +25 -3
- package/src/hooks/useUpdateMultipleExtProduct/index.js +33 -0
- package/src/hooks/useUpdateMultipleExtProduct/queries.js +33 -0
- package/src/hooks/useUploadProducts/index.js +0 -1
- package/src/hooks/useUser/queries.js +0 -1
- package/src/utils/index.js +97 -5
- package/tsconfig.json +5 -0
- package/src/hooks/useUpdateMultipleExtProductFoods/index.js +0 -21
- 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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
|
226
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
400
|
-
|
|
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
|
-
|
|
438
|
+
createdAt
|
|
426
439
|
required
|
|
427
|
-
|
|
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
|
-
|
|
438
|
-
|
|
450
|
+
createdAt
|
|
451
|
+
updatedAt
|
|
439
452
|
}
|
|
440
453
|
}
|
|
441
454
|
}
|
|
442
455
|
`
|
|
443
456
|
export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
-
|
|
457
|
-
|
|
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
|
-
|
|
617
|
-
|
|
657
|
+
createdAt
|
|
658
|
+
updatedAt
|
|
618
659
|
getOneTags {
|
|
619
|
-
|
|
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
|
-
|
|
632
|
-
|
|
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
|
-
|
|
642
|
-
|
|
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
|
|
750
|
-
|
|
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
|
-
|
|
812
|
-
|
|
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
|
-
|
|
826
|
-
|
|
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
|
-
|
|
891
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
31
|
+
createdAt
|
|
32
32
|
required
|
|
33
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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?.
|
|
116
|
-
const error = data?.registerSalesStore?.
|
|
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
|
|
129
|
+
setOpenCurrentSale(data?.registerSalesStore.success)
|
|
130
130
|
},
|
|
131
131
|
onError: (error) => {
|
|
132
132
|
sendNotification({
|
|
133
133
|
backgroundColor: 'error',
|
|
134
|
-
title: error
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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((
|
|
1086
|
-
if (
|
|
1087
|
-
const { data } =
|
|
1088
|
-
const { registerSalesStore } = data
|
|
1089
|
-
const {
|
|
1090
|
-
if (
|
|
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
|
-
|
|
1112
|
+
getOneSalesStore({
|
|
1103
1113
|
variables: {
|
|
1104
1114
|
pCodeRef: code || ''
|
|
1105
1115
|
}
|
|
1106
1116
|
}).then((responseSale) => {
|
|
1107
|
-
if (responseSale?.data?.
|
|
1108
|
-
const currentSale = responseSale?.data?.
|
|
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
|
|
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
|
-
|
|
1229
|
+
updateExtProductSubOptionalAll
|
|
1220
1230
|
}
|
|
1221
1231
|
})
|
|
1222
1232
|
.filter((obj) => obj)
|