npm-pkg-hook 1.3.7 → 1.3.9
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/.eslintrc.js +38 -38
- package/.eslintrc.json +127 -127
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/package.json +46 -46
- package/script.txt +6 -6
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -7
- package/src/hooks/getCategoriesWithProduct/index.js +62 -62
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/index.js +155 -155
- package/src/hooks/useAsideCart/queries.js +10 -10
- package/src/hooks/useCart/index.js +2 -2
- package/src/hooks/useCart/queries.js +164 -164
- package/src/hooks/useCart/useCart/helpers/index.js +75 -75
- package/src/hooks/useCart/useCart/index.js +410 -410
- package/src/hooks/useCart/useGetCart/index.js +31 -31
- package/src/hooks/useCatWithProductClient/index.js +56 -56
- package/src/hooks/useCatWithProductClient/queries.js +55 -55
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useChartData/useChartData/index.js +199 -199
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +52 -0
- package/src/hooks/useCreateProduct/index.js +8 -3
- package/src/hooks/useDeleteSubProductOptional/index.js +30 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDevices/index.js +35 -35
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -94
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEditSubProductOptional/queries.js +10 -10
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -19
- package/src/hooks/useFavoriteStores/queries.js +47 -47
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -172
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -14
- package/src/hooks/useGetFoodRecomended/index.js +32 -33
- package/src/hooks/useGetFoodRecomended/queries.js +47 -47
- package/src/hooks/useGetMinPrice/index.js +12 -12
- package/src/hooks/useGetMinPrice/queries.js +7 -7
- package/src/hooks/useGetOneStoreRating/index.js +40 -40
- package/src/hooks/useGetOneStoreRating/queries.js +18 -18
- package/src/hooks/useGoogleLogin/index.js +160 -160
- package/src/hooks/useGoogleLogin/loadScript.js +15 -15
- package/src/hooks/useGoogleLogin/removeScript.js +7 -7
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImagesStore/index.js +5 -4
- package/src/hooks/useInnerHtml/index.js +39 -39
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useLogout/index.js +29 -21
- package/src/hooks/useManageQueryParams/index.js +37 -36
- package/src/hooks/useMobile/index.js +39 -39
- package/src/hooks/useOrderClient/index.js +5 -5
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -12
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
- package/src/hooks/useProvidersStore/index.js +24 -24
- package/src/hooks/useProvidersStore/queries.js +31 -31
- package/src/hooks/useRatingArrayData/index.js +54 -54
- package/src/hooks/useRatingArrayData/queries.js +19 -19
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSchedule/index.js +72 -72
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +43 -43
- package/src/hooks/useScheduleData/index.js +123 -123
- package/src/hooks/useScroll/index.js +56 -56
- package/src/hooks/useScrollRotate/index.js +16 -16
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -101
- package/src/hooks/useStatusOpenStore/index.js +172 -172
- package/src/hooks/useStatusOrdersClient/queries.js +80 -80
- package/src/hooks/useStore/queries.js +163 -163
- package/src/hooks/useStoreCalendar/index.js +5 -5
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -38
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -8
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
|
|
3
|
-
export const CREATE_SHOPPING_CARD = gql`
|
|
4
|
-
mutation registerShoppingCard(
|
|
5
|
-
$input: IShoppingCard
|
|
6
|
-
$idSubArray: IID_SUB_ITEMS
|
|
7
|
-
) {
|
|
8
|
-
registerShoppingCard(input: $input, idSubArray: $idSubArray) {
|
|
9
|
-
ShoppingCard
|
|
10
|
-
id
|
|
11
|
-
pId
|
|
12
|
-
subProductsId
|
|
13
|
-
ShoppingCardRefCode
|
|
14
|
-
uuid
|
|
15
|
-
discountCardProduct
|
|
16
|
-
idUser
|
|
17
|
-
cName
|
|
18
|
-
idStore
|
|
19
|
-
cState
|
|
20
|
-
cDatCre
|
|
21
|
-
cDatMod
|
|
22
|
-
csDescription
|
|
23
|
-
cantProducts
|
|
24
|
-
comments
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
export const GET_ALL_SHOPPING_CARD = gql`
|
|
30
|
-
query getAllShoppingCard {
|
|
31
|
-
getAllShoppingCard {
|
|
32
|
-
ShoppingCard
|
|
33
|
-
cState
|
|
34
|
-
idStore
|
|
35
|
-
refCodePid
|
|
36
|
-
pId
|
|
37
|
-
comments
|
|
38
|
-
salesExtProductFoodOptional {
|
|
39
|
-
pId
|
|
40
|
-
opExPid
|
|
41
|
-
OptionalProName
|
|
42
|
-
state
|
|
43
|
-
code
|
|
44
|
-
required
|
|
45
|
-
numbersOptionalOnly
|
|
46
|
-
pDatCre
|
|
47
|
-
pDatMod
|
|
48
|
-
saleExtProductFoodsSubOptionalAll {
|
|
49
|
-
pId
|
|
50
|
-
opExPid
|
|
51
|
-
idStore
|
|
52
|
-
opSubExPid
|
|
53
|
-
OptionalSubProName
|
|
54
|
-
exCodeOptionExtra
|
|
55
|
-
exCode
|
|
56
|
-
state
|
|
57
|
-
pDatCre
|
|
58
|
-
pDatMod
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
ExtProductFoodsAll {
|
|
62
|
-
pId
|
|
63
|
-
exPid
|
|
64
|
-
exState
|
|
65
|
-
extraName
|
|
66
|
-
extraPrice
|
|
67
|
-
quantity
|
|
68
|
-
newExtraPrice
|
|
69
|
-
state
|
|
70
|
-
pDatCre
|
|
71
|
-
pDatMod
|
|
72
|
-
}
|
|
73
|
-
productFood {
|
|
74
|
-
pId
|
|
75
|
-
carProId
|
|
76
|
-
sizeId
|
|
77
|
-
colorId
|
|
78
|
-
idStore
|
|
79
|
-
cId
|
|
80
|
-
caId
|
|
81
|
-
dId
|
|
82
|
-
ctId
|
|
83
|
-
tpId
|
|
84
|
-
fId
|
|
85
|
-
pName
|
|
86
|
-
ProPrice
|
|
87
|
-
ProDescuento
|
|
88
|
-
ProUniDisponibles
|
|
89
|
-
ProDescription
|
|
90
|
-
ValueDelivery
|
|
91
|
-
ProProtegido
|
|
92
|
-
ProAssurance
|
|
93
|
-
ProImage
|
|
94
|
-
ProStar
|
|
95
|
-
ProWidth
|
|
96
|
-
ProHeight
|
|
97
|
-
ProLength
|
|
98
|
-
ProWeight
|
|
99
|
-
ProQuantity
|
|
100
|
-
ProOutstanding
|
|
101
|
-
ProDelivery
|
|
102
|
-
ProVoltaje
|
|
103
|
-
pState
|
|
104
|
-
sTateLogistic
|
|
105
|
-
pDatCre
|
|
106
|
-
pDatMod
|
|
107
|
-
}
|
|
108
|
-
cantProducts
|
|
109
|
-
getStore {
|
|
110
|
-
idStore
|
|
111
|
-
cId
|
|
112
|
-
id
|
|
113
|
-
dId
|
|
114
|
-
ctId
|
|
115
|
-
catStore
|
|
116
|
-
neighborhoodStore
|
|
117
|
-
Viaprincipal
|
|
118
|
-
storeOwner
|
|
119
|
-
storeName
|
|
120
|
-
emailStore
|
|
121
|
-
storePhone
|
|
122
|
-
socialRaz
|
|
123
|
-
Image
|
|
124
|
-
banner
|
|
125
|
-
documentIdentifier
|
|
126
|
-
uPhoNum
|
|
127
|
-
ULocation
|
|
128
|
-
upLat
|
|
129
|
-
upLon
|
|
130
|
-
uState
|
|
131
|
-
siteWeb
|
|
132
|
-
description
|
|
133
|
-
NitStore
|
|
134
|
-
typeRegiments
|
|
135
|
-
typeContribute
|
|
136
|
-
secVia
|
|
137
|
-
addressStore
|
|
138
|
-
createdAt
|
|
139
|
-
pais {
|
|
140
|
-
cId
|
|
141
|
-
cName
|
|
142
|
-
cCalCod
|
|
143
|
-
cState
|
|
144
|
-
cDatCre
|
|
145
|
-
cDatMod
|
|
146
|
-
}
|
|
147
|
-
city {
|
|
148
|
-
ctId
|
|
149
|
-
dId
|
|
150
|
-
cName
|
|
151
|
-
cState
|
|
152
|
-
}
|
|
153
|
-
department {
|
|
154
|
-
dId
|
|
155
|
-
cId
|
|
156
|
-
dName
|
|
157
|
-
dState
|
|
158
|
-
dDatCre
|
|
159
|
-
dDatMod
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const CREATE_SHOPPING_CARD = gql`
|
|
4
|
+
mutation registerShoppingCard(
|
|
5
|
+
$input: IShoppingCard
|
|
6
|
+
$idSubArray: IID_SUB_ITEMS
|
|
7
|
+
) {
|
|
8
|
+
registerShoppingCard(input: $input, idSubArray: $idSubArray) {
|
|
9
|
+
ShoppingCard
|
|
10
|
+
id
|
|
11
|
+
pId
|
|
12
|
+
subProductsId
|
|
13
|
+
ShoppingCardRefCode
|
|
14
|
+
uuid
|
|
15
|
+
discountCardProduct
|
|
16
|
+
idUser
|
|
17
|
+
cName
|
|
18
|
+
idStore
|
|
19
|
+
cState
|
|
20
|
+
cDatCre
|
|
21
|
+
cDatMod
|
|
22
|
+
csDescription
|
|
23
|
+
cantProducts
|
|
24
|
+
comments
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
export const GET_ALL_SHOPPING_CARD = gql`
|
|
30
|
+
query getAllShoppingCard {
|
|
31
|
+
getAllShoppingCard {
|
|
32
|
+
ShoppingCard
|
|
33
|
+
cState
|
|
34
|
+
idStore
|
|
35
|
+
refCodePid
|
|
36
|
+
pId
|
|
37
|
+
comments
|
|
38
|
+
salesExtProductFoodOptional {
|
|
39
|
+
pId
|
|
40
|
+
opExPid
|
|
41
|
+
OptionalProName
|
|
42
|
+
state
|
|
43
|
+
code
|
|
44
|
+
required
|
|
45
|
+
numbersOptionalOnly
|
|
46
|
+
pDatCre
|
|
47
|
+
pDatMod
|
|
48
|
+
saleExtProductFoodsSubOptionalAll {
|
|
49
|
+
pId
|
|
50
|
+
opExPid
|
|
51
|
+
idStore
|
|
52
|
+
opSubExPid
|
|
53
|
+
OptionalSubProName
|
|
54
|
+
exCodeOptionExtra
|
|
55
|
+
exCode
|
|
56
|
+
state
|
|
57
|
+
pDatCre
|
|
58
|
+
pDatMod
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ExtProductFoodsAll {
|
|
62
|
+
pId
|
|
63
|
+
exPid
|
|
64
|
+
exState
|
|
65
|
+
extraName
|
|
66
|
+
extraPrice
|
|
67
|
+
quantity
|
|
68
|
+
newExtraPrice
|
|
69
|
+
state
|
|
70
|
+
pDatCre
|
|
71
|
+
pDatMod
|
|
72
|
+
}
|
|
73
|
+
productFood {
|
|
74
|
+
pId
|
|
75
|
+
carProId
|
|
76
|
+
sizeId
|
|
77
|
+
colorId
|
|
78
|
+
idStore
|
|
79
|
+
cId
|
|
80
|
+
caId
|
|
81
|
+
dId
|
|
82
|
+
ctId
|
|
83
|
+
tpId
|
|
84
|
+
fId
|
|
85
|
+
pName
|
|
86
|
+
ProPrice
|
|
87
|
+
ProDescuento
|
|
88
|
+
ProUniDisponibles
|
|
89
|
+
ProDescription
|
|
90
|
+
ValueDelivery
|
|
91
|
+
ProProtegido
|
|
92
|
+
ProAssurance
|
|
93
|
+
ProImage
|
|
94
|
+
ProStar
|
|
95
|
+
ProWidth
|
|
96
|
+
ProHeight
|
|
97
|
+
ProLength
|
|
98
|
+
ProWeight
|
|
99
|
+
ProQuantity
|
|
100
|
+
ProOutstanding
|
|
101
|
+
ProDelivery
|
|
102
|
+
ProVoltaje
|
|
103
|
+
pState
|
|
104
|
+
sTateLogistic
|
|
105
|
+
pDatCre
|
|
106
|
+
pDatMod
|
|
107
|
+
}
|
|
108
|
+
cantProducts
|
|
109
|
+
getStore {
|
|
110
|
+
idStore
|
|
111
|
+
cId
|
|
112
|
+
id
|
|
113
|
+
dId
|
|
114
|
+
ctId
|
|
115
|
+
catStore
|
|
116
|
+
neighborhoodStore
|
|
117
|
+
Viaprincipal
|
|
118
|
+
storeOwner
|
|
119
|
+
storeName
|
|
120
|
+
emailStore
|
|
121
|
+
storePhone
|
|
122
|
+
socialRaz
|
|
123
|
+
Image
|
|
124
|
+
banner
|
|
125
|
+
documentIdentifier
|
|
126
|
+
uPhoNum
|
|
127
|
+
ULocation
|
|
128
|
+
upLat
|
|
129
|
+
upLon
|
|
130
|
+
uState
|
|
131
|
+
siteWeb
|
|
132
|
+
description
|
|
133
|
+
NitStore
|
|
134
|
+
typeRegiments
|
|
135
|
+
typeContribute
|
|
136
|
+
secVia
|
|
137
|
+
addressStore
|
|
138
|
+
createdAt
|
|
139
|
+
pais {
|
|
140
|
+
cId
|
|
141
|
+
cName
|
|
142
|
+
cCalCod
|
|
143
|
+
cState
|
|
144
|
+
cDatCre
|
|
145
|
+
cDatMod
|
|
146
|
+
}
|
|
147
|
+
city {
|
|
148
|
+
ctId
|
|
149
|
+
dId
|
|
150
|
+
cName
|
|
151
|
+
cState
|
|
152
|
+
}
|
|
153
|
+
department {
|
|
154
|
+
dId
|
|
155
|
+
cId
|
|
156
|
+
dName
|
|
157
|
+
dState
|
|
158
|
+
dDatCre
|
|
159
|
+
dDatMod
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { filterKeyObject } from '../../../../utils'
|
|
2
|
-
|
|
3
|
-
const filters = ['__typename']
|
|
4
|
-
|
|
5
|
-
export const filterDataOptional = (dataOptional) => {
|
|
6
|
-
if (!Array.isArray(dataOptional)) {
|
|
7
|
-
throw new Error('Input data is not an array')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const filteredDataOptional = dataOptional.map(item => {
|
|
12
|
-
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll?.filter(subItem => subItem.check === true)
|
|
13
|
-
const ExtProductFoodsSubOptionalAll = checkedSubOptions?.map(subItemsOptional => {
|
|
14
|
-
return {
|
|
15
|
-
...filterKeyObject(subItemsOptional, filters)
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
return {
|
|
19
|
-
...filterKeyObject(item, filters),
|
|
20
|
-
ExtProductFoodsSubOptionalAll
|
|
21
|
-
}
|
|
22
|
-
}).filter(item => item?.ExtProductFoodsSubOptionalAll.length > 0)
|
|
23
|
-
return filteredDataOptional
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error('An error occurred while filtering data:', error.message)
|
|
26
|
-
return []
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Valida los requerimientos de elementos opcionales.
|
|
32
|
-
* @param {Array} filteredDataOptional - El array de datos a validar.
|
|
33
|
-
* @returns {boolean} Devuelve true si se cumplen los requerimientos, de lo contrario, false.
|
|
34
|
-
*/
|
|
35
|
-
export function validateRequirements (filteredDataOptional) {
|
|
36
|
-
if (Array.isArray(filteredDataOptional)) {
|
|
37
|
-
for (const item of filteredDataOptional) {
|
|
38
|
-
if (item.required === 1) {
|
|
39
|
-
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll.filter(subItem => subItem.check === true)
|
|
40
|
-
if (checkedSubOptions.length !== item.numbersOptionalOnly) {
|
|
41
|
-
return true
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function validateExtraProducts (dataExtra) {
|
|
50
|
-
const requiredItems = dataExtra.filter(item => item.exState === 1)
|
|
51
|
-
|
|
52
|
-
if (requiredItems.length > 0) {
|
|
53
|
-
const hasSelectedRequiredProduct = requiredItems.some(item => item.quantity > 0)
|
|
54
|
-
return hasSelectedRequiredProduct
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const filterExtra = (dataExtra) => {
|
|
61
|
-
if (!Array.isArray(dataExtra)) {
|
|
62
|
-
throw new Error('Input data is not an array')
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
const dataExtraFiltered = dataExtra.filter(extra => extra.quantity !== 0)
|
|
66
|
-
.map(extra => {
|
|
67
|
-
return {
|
|
68
|
-
...filterKeyObject(extra, filters)
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
return dataExtraFiltered
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return []
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
import { filterKeyObject } from '../../../../utils'
|
|
2
|
+
|
|
3
|
+
const filters = ['__typename']
|
|
4
|
+
|
|
5
|
+
export const filterDataOptional = (dataOptional) => {
|
|
6
|
+
if (!Array.isArray(dataOptional)) {
|
|
7
|
+
throw new Error('Input data is not an array')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const filteredDataOptional = dataOptional.map(item => {
|
|
12
|
+
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll?.filter(subItem => subItem.check === true)
|
|
13
|
+
const ExtProductFoodsSubOptionalAll = checkedSubOptions?.map(subItemsOptional => {
|
|
14
|
+
return {
|
|
15
|
+
...filterKeyObject(subItemsOptional, filters)
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
return {
|
|
19
|
+
...filterKeyObject(item, filters),
|
|
20
|
+
ExtProductFoodsSubOptionalAll
|
|
21
|
+
}
|
|
22
|
+
}).filter(item => item?.ExtProductFoodsSubOptionalAll.length > 0)
|
|
23
|
+
return filteredDataOptional
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('An error occurred while filtering data:', error.message)
|
|
26
|
+
return []
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Valida los requerimientos de elementos opcionales.
|
|
32
|
+
* @param {Array} filteredDataOptional - El array de datos a validar.
|
|
33
|
+
* @returns {boolean} Devuelve true si se cumplen los requerimientos, de lo contrario, false.
|
|
34
|
+
*/
|
|
35
|
+
export function validateRequirements (filteredDataOptional) {
|
|
36
|
+
if (Array.isArray(filteredDataOptional)) {
|
|
37
|
+
for (const item of filteredDataOptional) {
|
|
38
|
+
if (item.required === 1) {
|
|
39
|
+
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll.filter(subItem => subItem.check === true)
|
|
40
|
+
if (checkedSubOptions.length !== item.numbersOptionalOnly) {
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function validateExtraProducts (dataExtra) {
|
|
50
|
+
const requiredItems = dataExtra.filter(item => item.exState === 1)
|
|
51
|
+
|
|
52
|
+
if (requiredItems.length > 0) {
|
|
53
|
+
const hasSelectedRequiredProduct = requiredItems.some(item => item.quantity > 0)
|
|
54
|
+
return hasSelectedRequiredProduct
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const filterExtra = (dataExtra) => {
|
|
61
|
+
if (!Array.isArray(dataExtra)) {
|
|
62
|
+
throw new Error('Input data is not an array')
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const dataExtraFiltered = dataExtra.filter(extra => extra.quantity !== 0)
|
|
66
|
+
.map(extra => {
|
|
67
|
+
return {
|
|
68
|
+
...filterKeyObject(extra, filters)
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
return dataExtraFiltered
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return []
|
|
74
|
+
}
|
|
75
|
+
}
|