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
package/.env
CHANGED
package/package.json
CHANGED
|
@@ -39,11 +39,12 @@
|
|
|
39
39
|
"type": "git",
|
|
40
40
|
"url": "https://github.com/Jesus123780/pkg-hook"
|
|
41
41
|
},
|
|
42
|
+
"private": false,
|
|
42
43
|
"scripts": {
|
|
43
44
|
"lint": "eslint .",
|
|
44
45
|
"lint:fix": "npm run lint -- --fix",
|
|
45
46
|
"rm": "rm -rf node_modules package-lock.json && npm i",
|
|
46
47
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
47
48
|
},
|
|
48
|
-
"version": "1.11.
|
|
49
|
-
}
|
|
49
|
+
"version": "1.11.7"
|
|
50
|
+
}
|
|
@@ -5,7 +5,7 @@ export const errorHandler = (error) => {
|
|
|
5
5
|
if (error && Array.isArray(error?.errors)) {
|
|
6
6
|
error.errors?.length && error?.errors?.forEach(err => {
|
|
7
7
|
if (err?.extensions) {
|
|
8
|
-
const { code, message
|
|
8
|
+
const { code, message } = err?.extensions || {}
|
|
9
9
|
if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
|
|
10
10
|
logout = true
|
|
11
11
|
return {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/config/content/index.js
|
|
2
|
+
|
|
3
|
+
import contentEn from './en.json'
|
|
4
|
+
import contentEs from './es.json'
|
|
5
|
+
|
|
6
|
+
const LANG = 'es'
|
|
7
|
+
|
|
8
|
+
const CONTENT = {
|
|
9
|
+
en: contentEn,
|
|
10
|
+
es: contentEs
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const t = (key) => {
|
|
14
|
+
const content = CONTENT[LANG] || {}
|
|
15
|
+
return content[key] || key
|
|
16
|
+
}
|
package/src/hooks/index.js
CHANGED
|
@@ -135,4 +135,10 @@ export * from './useSetImageProducts'
|
|
|
135
135
|
export * from './useGetSalesAmountToday'
|
|
136
136
|
export * from './useUpsertGoal'
|
|
137
137
|
export * from './useDashboardComponents'
|
|
138
|
+
export * from './useUpdateDashboardComponent'
|
|
138
139
|
export * from './useUpdateModuleOrder'
|
|
140
|
+
export * from './useDownloadReports'
|
|
141
|
+
export * from './usePortFetcher'
|
|
142
|
+
export * from './useImageUploaderProduct'
|
|
143
|
+
export * from './useTagProducts'
|
|
144
|
+
export * from './useOrderStatusTypes'
|
|
@@ -3,26 +3,15 @@ import { useSubscription, gql } from '@apollo/client'
|
|
|
3
3
|
const NEW_STORE_ORDER_SUBSCRIPTION = gql`
|
|
4
4
|
subscription NewStoreOrder($idStore: String!) {
|
|
5
5
|
newStoreOrder(idStore: $idStore) {
|
|
6
|
-
pdpId
|
|
7
6
|
id
|
|
8
7
|
idStore
|
|
9
|
-
pId
|
|
10
|
-
ppState
|
|
11
8
|
pCodeRef
|
|
12
|
-
pPDate
|
|
13
|
-
pSState
|
|
14
|
-
pPStateP
|
|
15
|
-
payMethodPState
|
|
16
|
-
pPRecoger
|
|
17
|
-
totalProductsPrice
|
|
18
|
-
unidProducts
|
|
19
|
-
pDatCre
|
|
20
|
-
pDatMod
|
|
21
9
|
}
|
|
22
10
|
}
|
|
23
11
|
`
|
|
24
12
|
|
|
25
13
|
export const newStoreOrderSubscription = (idStore, onOrderReceived) => {
|
|
14
|
+
console.log('🚀 ~ newStoreOrderSubscription ~ idStore:', idStore)
|
|
26
15
|
const subscription = useSubscription(NEW_STORE_ORDER_SUBSCRIPTION, {
|
|
27
16
|
variables: { idStore },
|
|
28
17
|
onSubscriptionData: ({ client, subscriptionData }) => {
|
|
@@ -3,7 +3,7 @@ import { updateCacheMod } from '../../utils'
|
|
|
3
3
|
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useProductsFood/queriesStore'
|
|
4
4
|
|
|
5
5
|
export const useUpdateExtProductFoodsOptional = () => {
|
|
6
|
-
const [
|
|
6
|
+
const [updateExtProductOptional] = useMutation(UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL)
|
|
7
7
|
|
|
8
8
|
const handleUpdateExtProduct = async ({
|
|
9
9
|
pId,
|
|
@@ -13,7 +13,7 @@ export const useUpdateExtProductFoodsOptional = () => {
|
|
|
13
13
|
required,
|
|
14
14
|
numbersOptionalOnly
|
|
15
15
|
}) => {
|
|
16
|
-
return await
|
|
16
|
+
return await updateExtProductOptional({
|
|
17
17
|
variables: {
|
|
18
18
|
input: {
|
|
19
19
|
pId,
|
|
@@ -49,8 +49,8 @@ mutation deleteCatFinalOfProducts($idPc: ID, $withProduct: Boolean) {
|
|
|
49
49
|
}
|
|
50
50
|
`
|
|
51
51
|
export const DELETE_EXTRA_PRODUCTS = gql`
|
|
52
|
-
mutation
|
|
53
|
-
|
|
52
|
+
mutation deleteExtraProduct($id: ID, $state: Int){
|
|
53
|
+
deleteExtraProduct(id: $id, state: $state){
|
|
54
54
|
success,
|
|
55
55
|
message
|
|
56
56
|
}
|
|
@@ -117,26 +117,42 @@ query ExtProductFoodsAll($search: String, $min: Int, $max: Int, $pId: ID) {
|
|
|
117
117
|
}
|
|
118
118
|
`
|
|
119
119
|
export const GET_ALL_CATEGORIES_WITH_PRODUCT = gql`
|
|
120
|
-
query getCatProductsWithProduct(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
query getCatProductsWithProduct(
|
|
121
|
+
$search: String
|
|
122
|
+
$productName: String
|
|
123
|
+
$min: Int
|
|
124
|
+
$max: Int
|
|
125
|
+
$gender: [String]
|
|
126
|
+
$desc: [String]
|
|
127
|
+
$categories: [ID]
|
|
128
|
+
) {
|
|
129
|
+
getCatProductsWithProduct(
|
|
130
|
+
search: $search
|
|
131
|
+
min: $min
|
|
132
|
+
productName: $productName
|
|
133
|
+
max: $max
|
|
134
|
+
gender: $gender
|
|
135
|
+
desc: $desc
|
|
136
|
+
categories: $categories
|
|
137
|
+
) {
|
|
130
138
|
totalCount
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
catProductsWithProduct {
|
|
140
|
+
carProId
|
|
141
|
+
pState
|
|
142
|
+
pState
|
|
143
|
+
ProImage
|
|
144
|
+
idStore
|
|
145
|
+
pName
|
|
146
|
+
totalCount
|
|
147
|
+
ProDescription
|
|
148
|
+
ProImage
|
|
149
|
+
pState
|
|
150
|
+
createdAt
|
|
151
|
+
updatedAt
|
|
152
|
+
productFoodsAll {
|
|
153
|
+
pId
|
|
154
|
+
stock
|
|
155
|
+
manageStock
|
|
140
156
|
sizeId
|
|
141
157
|
colorId
|
|
142
158
|
carProId
|
|
@@ -165,9 +181,19 @@ query getCatProductsWithProduct($search: String, $productName: String, $min: Int
|
|
|
165
181
|
ProVoltaje
|
|
166
182
|
pState
|
|
167
183
|
sTateLogistic
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
createdAt
|
|
185
|
+
updatedAt
|
|
186
|
+
product_availables {
|
|
187
|
+
availableProductId
|
|
188
|
+
pId
|
|
189
|
+
idStore
|
|
190
|
+
dayAvailable
|
|
191
|
+
startDate
|
|
192
|
+
endDate
|
|
193
|
+
createdAt
|
|
194
|
+
updatedAt
|
|
195
|
+
}
|
|
196
|
+
}
|
|
171
197
|
}
|
|
172
198
|
}
|
|
173
199
|
}
|
|
@@ -47,7 +47,6 @@ query getAllClients($idStore: ID, $search: String, $min: Int, $max: Int, $fromDa
|
|
|
47
47
|
success
|
|
48
48
|
message
|
|
49
49
|
data {
|
|
50
|
-
|
|
51
50
|
cliId
|
|
52
51
|
idStore
|
|
53
52
|
gender
|
|
@@ -134,29 +133,79 @@ mutation registerShoppingCard($input: IShoppingCard, $idSubArray: IID_SUB_ITEMS
|
|
|
134
133
|
}
|
|
135
134
|
`
|
|
136
135
|
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
137
|
-
mutation
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
136
|
+
mutation registerSalesStore(
|
|
137
|
+
$input: [IShoppingCart]
|
|
138
|
+
$id: ID
|
|
139
|
+
$tableId: ID
|
|
140
|
+
$discount: Int
|
|
141
|
+
$idStore: ID
|
|
142
|
+
$pCodeRef: String
|
|
143
|
+
$change: Float
|
|
144
|
+
$shoppingCartRefCode: String
|
|
145
|
+
$payMethodPState: Int
|
|
146
|
+
$pickUp: Int
|
|
147
|
+
$totalProductsPrice: Float
|
|
148
|
+
$valueDelivery: Float
|
|
149
|
+
$idSubArray: IID_SUB_ITEMS
|
|
150
|
+
) {
|
|
151
|
+
registerSalesStore(
|
|
152
|
+
input: $input
|
|
153
|
+
id: $id
|
|
154
|
+
tableId: $tableId
|
|
155
|
+
discount: $discount
|
|
156
|
+
shoppingCartRefCode: $shoppingCartRefCode
|
|
157
|
+
idStore: $idStore
|
|
158
|
+
pCodeRef: $pCodeRef
|
|
159
|
+
change: $change
|
|
160
|
+
|
|
161
|
+
payMethodPState: $payMethodPState
|
|
162
|
+
pickUp: $pickUp
|
|
163
|
+
totalProductsPrice: $totalProductsPrice
|
|
164
|
+
valueDelivery: $valueDelivery
|
|
165
|
+
idSubArray: $idSubArray
|
|
166
|
+
) {
|
|
167
|
+
success
|
|
168
|
+
message
|
|
169
|
+
errors {
|
|
170
|
+
path
|
|
159
171
|
message
|
|
172
|
+
type
|
|
173
|
+
context {
|
|
174
|
+
limit
|
|
175
|
+
value
|
|
176
|
+
label
|
|
177
|
+
key
|
|
178
|
+
__typename
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
data {
|
|
182
|
+
pCodeRef
|
|
183
|
+
idStore
|
|
184
|
+
id
|
|
185
|
+
channel
|
|
186
|
+
payMethodPState
|
|
187
|
+
pSState
|
|
188
|
+
createdAt
|
|
189
|
+
updatedAt
|
|
190
|
+
unidProducts
|
|
191
|
+
totalProductsPrice
|
|
192
|
+
getOneStore {
|
|
193
|
+
idStore
|
|
194
|
+
cId
|
|
195
|
+
dId
|
|
196
|
+
catStore
|
|
197
|
+
scheduleOpenAll
|
|
198
|
+
dailyGoal
|
|
199
|
+
deliveryTimeMinutes
|
|
200
|
+
}
|
|
201
|
+
getUser {
|
|
202
|
+
id
|
|
203
|
+
name
|
|
204
|
+
email
|
|
205
|
+
createdAt
|
|
206
|
+
updatedAt
|
|
207
|
+
__typename
|
|
208
|
+
}
|
|
160
209
|
}
|
|
161
210
|
}
|
|
162
211
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const MAX_PRICE =
|
|
1
|
+
const MAX_PRICE = 999999999999.99
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Verifica si alguno de los valores en el array excede el precio máximo.
|
|
@@ -9,7 +9,7 @@ const MAX_PRICE = 2147483647
|
|
|
9
9
|
*/
|
|
10
10
|
export const verifyPriceInRange = ({ values = [], sendNotification }) => {
|
|
11
11
|
const isAnyValueOutOfRange = values.some(value => value > MAX_PRICE)
|
|
12
|
-
|
|
12
|
+
// Si algún valor está fuera del rango, envía una notificación y retorna false
|
|
13
13
|
if (isAnyValueOutOfRange) {
|
|
14
14
|
sendNotification({
|
|
15
15
|
backgroundColor: 'warning',
|
|
@@ -4,19 +4,18 @@ import { useRef, useState } from 'react'
|
|
|
4
4
|
import { convertBase64, RandomCode } from '../../utils'
|
|
5
5
|
import { useLocalStorage } from '../useLocalSorage'
|
|
6
6
|
import {
|
|
7
|
-
GET_ALL_FOOD_PRODUCTS,
|
|
8
7
|
UPDATE_PRODUCT_FOOD
|
|
9
8
|
} from '../useProductsFood/queriesStore'
|
|
10
9
|
import { useStore } from '../useStore'
|
|
11
10
|
import { useTagsProducts } from './../useProductsFood/usetagsProducts'
|
|
12
11
|
import { useEditImageProduct } from './helpers/useEditImageProduct'
|
|
13
12
|
import { getCatProductsWithProduct } from './helpers/manageCacheDataCatProduct'
|
|
14
|
-
import { assignWith } from 'lodash'
|
|
15
13
|
import { UPDATE_IMAGE_PRODUCT_FOOD } from '../useSetImageProducts/queries'
|
|
16
14
|
import { useSetImageProducts } from '../useSetImageProducts'
|
|
17
15
|
|
|
18
16
|
export const useCreateProduct = ({
|
|
19
17
|
router,
|
|
18
|
+
image,
|
|
20
19
|
setAlertBox = (args) => { return args },
|
|
21
20
|
sendNotification = (args) => { return args }
|
|
22
21
|
}) => {
|
|
@@ -38,18 +37,24 @@ export const useCreateProduct = ({
|
|
|
38
37
|
ValueDelivery: 0,
|
|
39
38
|
carProId: ''
|
|
40
39
|
})
|
|
40
|
+
const STEPS = Object.freeze({
|
|
41
|
+
PRODUCT: 0,
|
|
42
|
+
DESSERTS: 1,
|
|
43
|
+
COMPLEMENTS: 2,
|
|
44
|
+
DISPONIBILITY: 3
|
|
45
|
+
})
|
|
46
|
+
|
|
41
47
|
const [updateImageProducts] = useSetImageProducts()
|
|
42
48
|
const [names, setName] = useLocalStorage('namefood', '')
|
|
43
49
|
const [showMore, setShowMore] = useState(50)
|
|
44
50
|
const [search, setSearch] = useState('')
|
|
45
51
|
const [imageBase64, setImageBase64] = useState(null)
|
|
46
|
-
const [active, setActive] = useState(
|
|
52
|
+
const [active, setActive] = useState(STEPS.PRODUCT)
|
|
47
53
|
const [pId, setPid] = useState(null)
|
|
48
54
|
|
|
49
55
|
const [searchFilter, setSearchFilter] = useState({ gender: [], desc: [], speciality: [] })
|
|
50
56
|
const [filter, setFilter] = useState({ gender: [], desc: [], speciality: [] })
|
|
51
57
|
const initialState = { alt: '/ images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' }
|
|
52
|
-
const [image, setImage] = useState(null)
|
|
53
58
|
const [{ alt, src }, setPreviewImg] = useState(initialState)
|
|
54
59
|
const fileInputRef = useRef(null)
|
|
55
60
|
const [arrTags, setTags] = useState([])
|
|
@@ -76,9 +81,12 @@ export const useCreateProduct = ({
|
|
|
76
81
|
const {
|
|
77
82
|
data,
|
|
78
83
|
tags,
|
|
84
|
+
setNewTags,
|
|
85
|
+
newTags,
|
|
86
|
+
handleRemoveTag,
|
|
79
87
|
handleRegister: handleRegisterTags,
|
|
80
88
|
handleAddTag
|
|
81
|
-
} = useTagsProducts()
|
|
89
|
+
} = useTagsProducts({ sendNotification })
|
|
82
90
|
|
|
83
91
|
// HANDLESS
|
|
84
92
|
const [check, setCheck] = useState({
|
|
@@ -105,8 +113,16 @@ export const useCreateProduct = ({
|
|
|
105
113
|
)
|
|
106
114
|
}
|
|
107
115
|
const handleChange = (e, error) => {
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
const { name, value } = e.target
|
|
117
|
+
setValues((prev) => ({
|
|
118
|
+
...prev,
|
|
119
|
+
[name]: value
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
setErrors((prev) => ({
|
|
123
|
+
...prev,
|
|
124
|
+
[name]: error
|
|
125
|
+
}))
|
|
110
126
|
}
|
|
111
127
|
const handleChangeFilter = e => {
|
|
112
128
|
setSearch(e.target.value)
|
|
@@ -144,23 +160,6 @@ export const useCreateProduct = ({
|
|
|
144
160
|
})
|
|
145
161
|
const [setImageProducts] = useMutation(UPDATE_IMAGE_PRODUCT_FOOD)
|
|
146
162
|
|
|
147
|
-
const onFileInputChange = async event => {
|
|
148
|
-
const { files } = event.target
|
|
149
|
-
|
|
150
|
-
const file = event.target.files[0]
|
|
151
|
-
setImage(file)
|
|
152
|
-
const base64 = await convertBase64(file)
|
|
153
|
-
// const [size, { unit }] = await getFileSizeByUnit(file, "B");
|
|
154
|
-
setImageBase64(base64)
|
|
155
|
-
setPreviewImg(
|
|
156
|
-
files.length
|
|
157
|
-
? {
|
|
158
|
-
src: URL.createObjectURL(files[0]),
|
|
159
|
-
alt: files[0].name
|
|
160
|
-
}
|
|
161
|
-
: initialState
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
163
|
const onTargetClick = () => {
|
|
165
164
|
if (fileInputRef.current) {
|
|
166
165
|
fileInputRef.current.click()
|
|
@@ -187,16 +186,15 @@ export const useCreateProduct = ({
|
|
|
187
186
|
ValueDelivery: 0,
|
|
188
187
|
carProId: ''
|
|
189
188
|
}
|
|
190
|
-
const formatPrice = ProPrice ?? 0
|
|
191
189
|
if (!carProId && !names) return setErrors({ ...errors, carProId: true })
|
|
192
190
|
const ProImage = '/images/placeholder-image.webp'
|
|
193
|
-
const pCode = RandomCode(
|
|
191
|
+
const pCode = RandomCode(10)
|
|
194
192
|
try {
|
|
195
|
-
const
|
|
193
|
+
const response = await updateProductFoods({
|
|
196
194
|
variables: {
|
|
197
195
|
input: {
|
|
198
196
|
idStore: dataStore?.getStore?.idStore || '',
|
|
199
|
-
ProPrice: check?.desc ? 0 :
|
|
197
|
+
ProPrice: check?.desc ? 0 : ProPrice,
|
|
200
198
|
ProDescuento: check?.desc ? 0 : ProDescuento,
|
|
201
199
|
ValueDelivery: check?.desc ? 0 : ValueDelivery,
|
|
202
200
|
ProDescription,
|
|
@@ -214,7 +212,7 @@ export const useCreateProduct = ({
|
|
|
214
212
|
ProOutstanding: check?.desc ? 1 : 0,
|
|
215
213
|
ProDelivery: check?.desc ? 1 : 0
|
|
216
214
|
}
|
|
217
|
-
}
|
|
215
|
+
}
|
|
218
216
|
// update (cache) {
|
|
219
217
|
// cache.modify({
|
|
220
218
|
// fields: {
|
|
@@ -228,18 +226,18 @@ export const useCreateProduct = ({
|
|
|
228
226
|
// }
|
|
229
227
|
// })
|
|
230
228
|
// }
|
|
231
|
-
}).finally(() => {
|
|
232
|
-
setValues({
|
|
233
|
-
ProPrice: 0,
|
|
234
|
-
ProDescuento: 0,
|
|
235
|
-
ProDescription: '',
|
|
236
|
-
ProWeight: '',
|
|
237
|
-
ProHeight: '',
|
|
238
|
-
ValueDelivery: 0,
|
|
239
|
-
carProId: ''
|
|
240
|
-
})
|
|
241
229
|
})
|
|
242
|
-
const {
|
|
230
|
+
const { data } = response
|
|
231
|
+
const { updateProductFoods: dataResponse } = data
|
|
232
|
+
const { success, data: productData } = dataResponse
|
|
233
|
+
const { pId } = productData
|
|
234
|
+
if (success) {
|
|
235
|
+
handleRegisterTags({
|
|
236
|
+
pId,
|
|
237
|
+
nameTag: tags?.tag ?? null
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
const { errors } = response?.data?.updateProductFoods ?? {
|
|
243
241
|
errors: []
|
|
244
242
|
}
|
|
245
243
|
if (errors?.length > 0) {
|
|
@@ -253,10 +251,9 @@ export const useCreateProduct = ({
|
|
|
253
251
|
return
|
|
254
252
|
}
|
|
255
253
|
if (image !== null) {
|
|
256
|
-
console.log(image)
|
|
257
254
|
try {
|
|
258
255
|
await updateImageProducts({
|
|
259
|
-
pId:
|
|
256
|
+
pId: response?.data?.updateProductFoods?.data?.pId,
|
|
260
257
|
image
|
|
261
258
|
})
|
|
262
259
|
} catch {
|
|
@@ -267,10 +264,9 @@ export const useCreateProduct = ({
|
|
|
267
264
|
})
|
|
268
265
|
}
|
|
269
266
|
}
|
|
270
|
-
setPid(
|
|
271
|
-
return
|
|
267
|
+
setPid(response?.data?.updateProductFoods?.data?.pId ?? null)
|
|
268
|
+
return response
|
|
272
269
|
} catch (error) {
|
|
273
|
-
console.log('🚀 ~ handleRegister ~ error:', error)
|
|
274
270
|
setAlertBox({ message: 'Ha ocurrido un error', duration: 7000 })
|
|
275
271
|
}
|
|
276
272
|
}
|
|
@@ -308,6 +304,8 @@ export const useCreateProduct = ({
|
|
|
308
304
|
active,
|
|
309
305
|
idStore: dataStore?.getStore?.idStore || '',
|
|
310
306
|
arrTags,
|
|
307
|
+
newTags,
|
|
308
|
+
setNewTags,
|
|
311
309
|
setPid,
|
|
312
310
|
handleChange,
|
|
313
311
|
onClickClear,
|
|
@@ -322,12 +320,13 @@ export const useCreateProduct = ({
|
|
|
322
320
|
setCheck,
|
|
323
321
|
handleRegister,
|
|
324
322
|
setActive,
|
|
325
|
-
|
|
323
|
+
STEPS,
|
|
326
324
|
handleRegisterTags,
|
|
327
325
|
setShowMore,
|
|
328
326
|
handleCheckStock,
|
|
329
327
|
onTargetClick,
|
|
330
328
|
handleAddTag,
|
|
329
|
+
handleRemoveTag,
|
|
331
330
|
handleCheck,
|
|
332
331
|
handleCheckFreeShipping,
|
|
333
332
|
check
|
|
@@ -73,7 +73,9 @@ export const useDessert = ({
|
|
|
73
73
|
// Here, it seems to exclude a specific list ID ('01list') from the listIds.
|
|
74
74
|
|
|
75
75
|
// HOOKS
|
|
76
|
-
const { handleMutateExtProductFoodsSubOptional } = useUpdateExtProductFoodsSubOptional(
|
|
76
|
+
const { handleMutateExtProductFoodsSubOptional } = useUpdateExtProductFoodsSubOptional({
|
|
77
|
+
sendNotification
|
|
78
|
+
})
|
|
77
79
|
const { handleUpdateExtProduct } = useUpdateExtProductFoodsOptional()
|
|
78
80
|
const { DeleteExtProductFoodsOptional } = useRemoveExtraProductFoodsOptional()
|
|
79
81
|
const [DeleteExtFoodSubsOptional] = useDeleteSubProductOptional()
|
|
@@ -323,14 +325,14 @@ export const useDessert = ({
|
|
|
323
325
|
numbersOptionalOnly: numberLimit
|
|
324
326
|
})
|
|
325
327
|
const { data } = response || {}
|
|
326
|
-
if (!data?.
|
|
328
|
+
if (!data?.updateExtProductOptional) {
|
|
327
329
|
return sendNotification({
|
|
328
330
|
description: 'Ocurrió un error, intenta de nuevo',
|
|
329
331
|
title: 'Error',
|
|
330
332
|
backgroundColor: 'warning'
|
|
331
333
|
})
|
|
332
334
|
}
|
|
333
|
-
const { success, message } = data?.
|
|
335
|
+
const { success, message } = data?.updateExtProductOptional || {}
|
|
334
336
|
if (success) {
|
|
335
337
|
setSelectedExtra({})
|
|
336
338
|
setOpenModalEditExtra(false)
|
|
@@ -397,6 +399,21 @@ export const useDessert = ({
|
|
|
397
399
|
addCard(valueItems, listId)
|
|
398
400
|
}
|
|
399
401
|
setValueItems('')
|
|
402
|
+
// Reset the value of all lists in dataListIds to 0 in a single setData call
|
|
403
|
+
setData(prevData => {
|
|
404
|
+
const updatedLists = Object.fromEntries(
|
|
405
|
+
Object.entries(prevData.lists).map(([listId, list]) => {
|
|
406
|
+
if (dataListIds.includes(listId)) {
|
|
407
|
+
return [listId, { ...list, value: '' }]
|
|
408
|
+
}
|
|
409
|
+
return [listId, list]
|
|
410
|
+
})
|
|
411
|
+
)
|
|
412
|
+
return {
|
|
413
|
+
...prevData,
|
|
414
|
+
lists: updatedLists
|
|
415
|
+
}
|
|
416
|
+
})
|
|
400
417
|
}
|
|
401
418
|
|
|
402
419
|
/**
|
|
@@ -10,7 +10,7 @@ export const transformData = (dataExtra) => {
|
|
|
10
10
|
return transformedData
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const MAX_INTEGER =
|
|
13
|
+
export const MAX_INTEGER = 999999999999.99
|
|
14
14
|
/**
|
|
15
15
|
* Validate if a number is within a specified range.
|
|
16
16
|
* @param {number} num - The number to validate.
|
|
@@ -60,7 +60,7 @@ export const updateErrorFieldByIndex = ({
|
|
|
60
60
|
|
|
61
61
|
// Actualiza el campo 'error' del elemento a true
|
|
62
62
|
updatedLine.error = true
|
|
63
|
-
updatedLine.messageError = 'El precio no puede ser mayor a
|
|
63
|
+
updatedLine.messageError = 'El precio no puede ser mayor a 999999999999.99'
|
|
64
64
|
|
|
65
65
|
// Devuelve el elemento actualizado
|
|
66
66
|
return updatedLine
|