npm-pkg-hook 1.7.5 → 1.7.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/package.json +1 -1
- package/src/hooks/updateExtProductFoodsOptional/index.js +1 -1
- package/src/hooks/useDessert/index.js +7 -6
- package/src/hooks/useProductsFood/index.js +10 -10
- package/src/hooks/useSales/helpers/index.js +23 -5
- package/src/hooks/useSales/index.js +4 -18
- package/src/utils/index.js +14 -0
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ export * from './helpers'
|
|
|
15
15
|
export const useDessert = ({
|
|
16
16
|
pId = null,
|
|
17
17
|
initialData = null,
|
|
18
|
-
sendNotification = () => { }
|
|
18
|
+
sendNotification = (args) => { return args }
|
|
19
19
|
}) => {
|
|
20
20
|
const [selectedExtra, setSelectedExtra] = useState({})
|
|
21
21
|
const [openModalEditExtra, setOpenModalEditExtra] = useState(false)
|
|
@@ -413,6 +413,7 @@ export const useDessert = ({
|
|
|
413
413
|
title: 'Error',
|
|
414
414
|
backgroundColor: 'warning'
|
|
415
415
|
})
|
|
416
|
+
return // Termina la función si el título está vacío
|
|
416
417
|
}
|
|
417
418
|
|
|
418
419
|
// Generate a new list ID using the RandomCode function (must be implemented elsewhere)
|
|
@@ -421,11 +422,11 @@ export const useDessert = ({
|
|
|
421
422
|
// Determine if the list is required based on the setCheck.exState state
|
|
422
423
|
const required = setCheck.exState ? 1 : 0
|
|
423
424
|
|
|
424
|
-
// Add the new list to the data state
|
|
425
|
-
setData({
|
|
426
|
-
listIds: [...
|
|
425
|
+
// Add the new list to the beginning of the data state
|
|
426
|
+
setData(prevData => ({
|
|
427
|
+
listIds: [newListId, ...prevData.listIds], // Agrega el nuevo ID al principio del array
|
|
427
428
|
lists: {
|
|
428
|
-
...
|
|
429
|
+
...prevData.lists,
|
|
429
430
|
[newListId]: {
|
|
430
431
|
id: newListId,
|
|
431
432
|
title,
|
|
@@ -435,7 +436,7 @@ export const useDessert = ({
|
|
|
435
436
|
cards: []
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
|
-
})
|
|
439
|
+
}))
|
|
439
440
|
|
|
440
441
|
// Update the external product with the information of the new list
|
|
441
442
|
handleUpdateExtProduct({
|
|
@@ -16,10 +16,10 @@ export * from './useEditProduct'
|
|
|
16
16
|
export const useProductsFood = ({
|
|
17
17
|
categories,
|
|
18
18
|
desc,
|
|
19
|
-
fetchPolicy = 'network
|
|
19
|
+
fetchPolicy = 'cache-and-network',
|
|
20
20
|
fromDate,
|
|
21
21
|
gender,
|
|
22
|
-
max =
|
|
22
|
+
max = 100,
|
|
23
23
|
min,
|
|
24
24
|
pState,
|
|
25
25
|
search = null,
|
|
@@ -28,7 +28,7 @@ export const useProductsFood = ({
|
|
|
28
28
|
// const [productsFood, setProductsFood] = useState([])
|
|
29
29
|
const [showMore, setShowMore] = useState(500)
|
|
30
30
|
const { data, loading, fetchMore, error, called } = useQuery(GET_ALL_PRODUCT_STORE, {
|
|
31
|
-
fetchPolicy
|
|
31
|
+
fetchPolicy,
|
|
32
32
|
notifyOnNetworkStatusChange: true,
|
|
33
33
|
nextFetchPolicy: 'cache-first',
|
|
34
34
|
refetchWritePolicy: 'merge',
|
|
@@ -40,7 +40,7 @@ export const useProductsFood = ({
|
|
|
40
40
|
gender: gender || [],
|
|
41
41
|
max: max || null,
|
|
42
42
|
min: min || null,
|
|
43
|
-
pState
|
|
43
|
+
pState,
|
|
44
44
|
search: search ?? search,
|
|
45
45
|
toDate: toDate || null
|
|
46
46
|
}
|
|
@@ -59,11 +59,11 @@ export const useProductsFood = ({
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export const useDeleteProductsFood = ({
|
|
62
|
-
sendNotification = (
|
|
63
|
-
onSuccess = (
|
|
62
|
+
sendNotification = (arg) => { return arg },
|
|
63
|
+
onSuccess = (arg) => { return arg }
|
|
64
64
|
} = {
|
|
65
|
-
sendNotification: (
|
|
66
|
-
onSuccess: (
|
|
65
|
+
sendNotification: (arg) => { return arg },
|
|
66
|
+
onSuccess: (arg) => { return arg }
|
|
67
67
|
}) => {
|
|
68
68
|
const [updateProductFoods, { data, loading, error }] = useMutation(UPDATE_PRODUCT_FOOD)
|
|
69
69
|
|
|
@@ -124,8 +124,8 @@ export const useDeleteProductsFood = ({
|
|
|
124
124
|
}).then(() => {
|
|
125
125
|
onSuccess()
|
|
126
126
|
return sendNotification({
|
|
127
|
-
title: '
|
|
128
|
-
description: 'El producto se ha eliminado correctamente',
|
|
127
|
+
title: 'Éxito',
|
|
128
|
+
description: pState === 1 ? 'El producto se ha eliminado correctamente' : 'El producto se ha restaurando correctamente',
|
|
129
129
|
backgroundColor: 'success'
|
|
130
130
|
})
|
|
131
131
|
}).catch((e) => {
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
export function convertToIntegerOrFloat(numberString) {
|
|
2
|
-
|
|
1
|
+
export function convertToIntegerOrFloat (numberString) {
|
|
2
|
+
if (!numberString) return 0
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// Convierte a número (entero o flotante)
|
|
5
|
+
const numericValue = parseFloat(numberString)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
return isNaN(numericValue) ? 0 : numericValue // Maneja valores no numéricos como 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Filter products by carProId.
|
|
12
|
+
* @param {Array} products - Array of products to filter.
|
|
13
|
+
* @param {Array} carProIds - Array of carProId to filter by.
|
|
14
|
+
* @returns {Array} - Filtered array of products or all products if no matches found.
|
|
15
|
+
*/
|
|
16
|
+
export function filterProductsByCarProId (products, carProIds) {
|
|
17
|
+
if (!Array.isArray(products)) {
|
|
18
|
+
return []
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!Array.isArray(carProIds) || carProIds.length === 0) {
|
|
22
|
+
return products
|
|
8
23
|
}
|
|
24
|
+
|
|
25
|
+
return products.filter(product => carProIds.includes(product.carProId))
|
|
26
|
+
}
|
|
@@ -28,7 +28,10 @@ import { updateExistingOrders } from '../useUpdateExistingOrders'
|
|
|
28
28
|
import { useGetSale } from './useGetSale'
|
|
29
29
|
import { useCatWithProduct } from './../useCatWithProduct/index'
|
|
30
30
|
import { useLogout } from '../useLogout'
|
|
31
|
+
import { filterProductsByCarProId } from './helpers'
|
|
31
32
|
export * from './useGetAllSales'
|
|
33
|
+
export * from './helpers'
|
|
34
|
+
|
|
32
35
|
export { GET_ALL_COUNT_SALES } from './queries'
|
|
33
36
|
|
|
34
37
|
const initialState = {
|
|
@@ -634,7 +637,7 @@ export const useSales = ({
|
|
|
634
637
|
if (item.pId === pId) {
|
|
635
638
|
return {
|
|
636
639
|
...item,
|
|
637
|
-
getOneTags: OurProduct
|
|
640
|
+
getOneTags: OurProduct?.genderTags,
|
|
638
641
|
unitPrice: OurProduct?.ProPrice,
|
|
639
642
|
ProPrice: isFree ? 0 : (productExist.ProQuantity + 1) * OurProduct?.ProPrice,
|
|
640
643
|
ProQuantity: productExist.ProQuantity + +1,
|
|
@@ -1081,23 +1084,6 @@ export const useSales = ({
|
|
|
1081
1084
|
}
|
|
1082
1085
|
|
|
1083
1086
|
const disabledModalItems = (dataOptional?.length > 0 || dataExtra?.length > 0) && !loadingExtProductFoodsSubOptionalAll
|
|
1084
|
-
/**
|
|
1085
|
-
* Filter products by carProId.
|
|
1086
|
-
* @param {Array} products - Array of products to filter.
|
|
1087
|
-
* @param {Array} carProIds - Array of carProId to filter by.
|
|
1088
|
-
* @returns {Array} - Filtered array of products or all products if no matches found.
|
|
1089
|
-
*/
|
|
1090
|
-
function filterProductsByCarProId (products, carProIds) {
|
|
1091
|
-
if (!Array.isArray(products)) {
|
|
1092
|
-
return []
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
if (!Array.isArray(carProIds) || carProIds.length === 0) {
|
|
1096
|
-
return products
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
return products.filter(product => carProIds.includes(product.carProId))
|
|
1100
|
-
}
|
|
1101
1087
|
|
|
1102
1088
|
/**
|
|
1103
1089
|
* Filter objects with checked property equal to true.
|
package/src/utils/index.js
CHANGED
|
@@ -13,6 +13,20 @@ const validTypes = {
|
|
|
13
13
|
textarea: true
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export const statusOrder = {
|
|
17
|
+
0: '',
|
|
18
|
+
1: 'ENTRANTE',
|
|
19
|
+
2: 'PROCESO',
|
|
20
|
+
3: 'LISTOS',
|
|
21
|
+
4: 'CONCLUIDOS',
|
|
22
|
+
5: 'RECHAZADOS'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const statusProduct = {
|
|
26
|
+
deleted: 0,
|
|
27
|
+
active: 1
|
|
28
|
+
}
|
|
29
|
+
|
|
16
30
|
export const validationSubmitHooks = elements => {
|
|
17
31
|
let errorForm = {}
|
|
18
32
|
|