npm-pkg-hook 1.2.2 → 1.2.5
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/useDessert/index.js +7 -6
- package/src/hooks/useEditOneExtProductFoodOptional/index.js +28 -0
- package/src/hooks/useEditOneExtProductFoodOptional/queries.js +16 -0
- package/src/hooks/useProductsFood/queriesStore.js +17 -2
- package/src/hooks/useProductsFood/usetagsProducts.js +1 -1
- package/src/hooks/useSales/helpers/index.js +2 -3
- package/src/hooks/useSales/index.js +26 -11
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +10 -2
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import { useRemoveExtraProductFoodsOptional } from '../useRemoveExtraProductFood
|
|
|
11
11
|
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useRemoveExtraProductFoodsOptional/queries'
|
|
12
12
|
import { transformDataToDessert } from './helpers'
|
|
13
13
|
import { useDeleteSubProductOptional } from '../useDeleteSubProductOptional'
|
|
14
|
-
|
|
14
|
+
export * from './helpers'
|
|
15
15
|
export const useDessert = ({
|
|
16
16
|
pId = null,
|
|
17
17
|
initialData = null,
|
|
@@ -50,15 +50,16 @@ export const useDessert = ({
|
|
|
50
50
|
}
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
// Transform initialData using useMemo to prevent unnecessary re-computation
|
|
54
|
-
const transformedData = useMemo(() => transformDataToDessert(initialData), [initialData])
|
|
55
|
-
|
|
56
53
|
// Use useEffect to update the data state when the initialData prop changes
|
|
57
54
|
useEffect(() => {
|
|
58
55
|
if (initialData) {
|
|
59
|
-
|
|
56
|
+
// Only update the data state if it's different from initialData
|
|
57
|
+
if (JSON.stringify(data) !== JSON.stringify(transformDataToDessert(initialData))) {
|
|
58
|
+
const transformedInitialData = transformDataToDessert(initialData);
|
|
59
|
+
setData(transformedInitialData);
|
|
60
|
+
}
|
|
60
61
|
}
|
|
61
|
-
}, [])
|
|
62
|
+
}, [initialData]); // Include data as a dependency
|
|
62
63
|
|
|
63
64
|
// Filter the 'listIds' from 'data' and store the filtered result in 'dataListIds'
|
|
64
65
|
// Here, it seems to exclude a specific list ID ('01list') from the listIds.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useMutation } from '@apollo/client'
|
|
4
|
+
import { UPDATE_EXT_PRODUCT_FOOD_OPTIONAL } from './queries';
|
|
5
|
+
export const useEditOneExtProductFoodOptional = () => {
|
|
6
|
+
const [updateExtProductFood] = useMutation(UPDATE_EXT_PRODUCT_FOOD_OPTIONAL);
|
|
7
|
+
const [loading, setLoading] = useState(false);
|
|
8
|
+
|
|
9
|
+
const updateOneExtraProductFood = async (input) => {
|
|
10
|
+
setLoading(true);
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const { data } = await updateExtProductFood({
|
|
14
|
+
variables: { input }
|
|
15
|
+
});
|
|
16
|
+
console.log('Product food updated:', data.editExtProductFoodOptional);
|
|
17
|
+
setLoading(false);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error updating product food:', error.message);
|
|
20
|
+
setLoading(false);
|
|
21
|
+
throw new Error('Error updating product food');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
loading,
|
|
26
|
+
updateOneExtraProductFood
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { gql } from "@apollo/client"
|
|
2
|
+
|
|
3
|
+
export const UPDATE_EXT_PRODUCT_FOOD_OPTIONAL = gql`
|
|
4
|
+
mutation editExtProductFoodOptional($input: EditExtProductFoodOptionalInput!) {
|
|
5
|
+
editExtProductFoodOptional(input: $input) {
|
|
6
|
+
pId
|
|
7
|
+
opExPid
|
|
8
|
+
OptionalProName
|
|
9
|
+
state
|
|
10
|
+
code
|
|
11
|
+
required
|
|
12
|
+
numbersOptionalOnly
|
|
13
|
+
pDatMod
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`
|
|
@@ -575,7 +575,7 @@ export const SET_EDIT_STORE_NAME = gql`
|
|
|
575
575
|
}
|
|
576
576
|
`
|
|
577
577
|
export const GET_ONE_PRODUCTS_FOOD = gql`
|
|
578
|
-
|
|
578
|
+
query productFoodsOne($pId: ID) {
|
|
579
579
|
productFoodsOne(pId: $pId) {
|
|
580
580
|
pId
|
|
581
581
|
carProId
|
|
@@ -588,7 +588,6 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
|
|
|
588
588
|
dId
|
|
589
589
|
ctId
|
|
590
590
|
tpId
|
|
591
|
-
|
|
592
591
|
fId
|
|
593
592
|
pName
|
|
594
593
|
ProPrice
|
|
@@ -612,6 +611,22 @@ export const GET_ONE_PRODUCTS_FOOD = gql`
|
|
|
612
611
|
sTateLogistic
|
|
613
612
|
pDatCre
|
|
614
613
|
pDatMod
|
|
614
|
+
getOneTags {
|
|
615
|
+
tPsId
|
|
616
|
+
idUser
|
|
617
|
+
idStore
|
|
618
|
+
pId
|
|
619
|
+
nameTag
|
|
620
|
+
aName
|
|
621
|
+
}
|
|
622
|
+
getAllAvailableProduct {
|
|
623
|
+
availableProductId
|
|
624
|
+
idStore
|
|
625
|
+
pId
|
|
626
|
+
dayAvailable
|
|
627
|
+
pDatCre
|
|
628
|
+
pDatMod
|
|
629
|
+
}
|
|
615
630
|
ExtProductFoodsAll {
|
|
616
631
|
pId
|
|
617
632
|
exPid
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export function convertToIntegerOrFloat(numberString) {
|
|
2
2
|
if (!numberString) return 0;
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
// Convierte a número (entero o flotante)
|
|
5
5
|
const numericValue = parseFloat(numberString);
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
return isNaN(numericValue) ? 0 : numericValue; // Maneja valores no numéricos como 0
|
|
8
8
|
}
|
|
9
|
-
|
|
@@ -347,6 +347,11 @@ export const useSales = ({
|
|
|
347
347
|
...values,
|
|
348
348
|
[name]: value ?? ''
|
|
349
349
|
})
|
|
350
|
+
sendNotification({
|
|
351
|
+
backgroundColor: 'sucess',
|
|
352
|
+
title: 'Comentario eliminado',
|
|
353
|
+
description: 'Has eliminado el comentario!'
|
|
354
|
+
})
|
|
350
355
|
return dispatch({
|
|
351
356
|
type: 'PUT_COMMENT',
|
|
352
357
|
payload: pId,
|
|
@@ -451,14 +456,14 @@ export const useSales = ({
|
|
|
451
456
|
})
|
|
452
457
|
.filter((obj) => obj !== null) // Elimine todos los objetos nulos del arreglo
|
|
453
458
|
const filteredDataExtra = dataExtra?.filter((p) => p?.quantity !== undefined && p?.quantity !== 0);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
if (product?.PRODUCT?.pId) {
|
|
460
|
+
dispatch({
|
|
461
|
+
type: 'PUT_EXTRA_PRODUCTS_AND_OPTIONAL_PRODUCT',
|
|
462
|
+
payload: product.PRODUCT.pId,
|
|
463
|
+
dataOptional: filteredDataOptional,
|
|
464
|
+
dataExtra: filteredDataExtra
|
|
465
|
+
})
|
|
466
|
+
}
|
|
462
467
|
} catch (_error) {
|
|
463
468
|
return sendNotification({
|
|
464
469
|
title: 'Error',
|
|
@@ -647,6 +652,14 @@ export const useSales = ({
|
|
|
647
652
|
|
|
648
653
|
// COMMENT_FREE_PRODUCT
|
|
649
654
|
function commentProducts (state, action, deleteValue) {
|
|
655
|
+
if (values.comment) {
|
|
656
|
+
sendNotification({
|
|
657
|
+
backgroundColor: 'success',
|
|
658
|
+
title: deleteValue ? 'Comentario eliminado' : 'Producto comentado',
|
|
659
|
+
description: deleteValue ? 'Has eliminado el comentario!' : 'Has comentado!'
|
|
660
|
+
})
|
|
661
|
+
}
|
|
662
|
+
setOpenCommentModal(!openCommentModal)
|
|
650
663
|
return {
|
|
651
664
|
...state,
|
|
652
665
|
PRODUCT: state?.PRODUCT?.map((items) => {
|
|
@@ -834,7 +847,7 @@ export const useSales = ({
|
|
|
834
847
|
const { registerSalesStore } = data || {}
|
|
835
848
|
const { Response } = registerSalesStore || {}
|
|
836
849
|
if (Response && Response.success === true) {
|
|
837
|
-
|
|
850
|
+
setPrint(false)
|
|
838
851
|
client.query({
|
|
839
852
|
query: GET_ALL_COUNT_SALES,
|
|
840
853
|
fetchPolicy: 'network-only',
|
|
@@ -855,7 +868,8 @@ export const useSales = ({
|
|
|
855
868
|
fields: {
|
|
856
869
|
getAllOrdersFromStore (existingOrders = []) {
|
|
857
870
|
try {
|
|
858
|
-
|
|
871
|
+
const newGetAllOrdersFromStore = updateExistingOrders(existingOrders, inComingCodeRef, 4, currentSale)
|
|
872
|
+
return newGetAllOrdersFromStore
|
|
859
873
|
} catch (e) {
|
|
860
874
|
return existingOrders
|
|
861
875
|
}
|
|
@@ -874,7 +888,6 @@ export const useSales = ({
|
|
|
874
888
|
undefined,
|
|
875
889
|
{ shallow: true }
|
|
876
890
|
)
|
|
877
|
-
setValues({})
|
|
878
891
|
}
|
|
879
892
|
}
|
|
880
893
|
setLoadingSale(false)
|
|
@@ -882,8 +895,10 @@ export const useSales = ({
|
|
|
882
895
|
.catch(() => {
|
|
883
896
|
setLoadingSale(false)
|
|
884
897
|
setErrorSale(true)
|
|
898
|
+
setPrint(false)
|
|
885
899
|
})
|
|
886
900
|
.finally(() => {
|
|
901
|
+
setPrint(false)
|
|
887
902
|
setLoadingSale(false)
|
|
888
903
|
})
|
|
889
904
|
}
|
|
@@ -9,7 +9,7 @@ export const days = [
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
day: 3,
|
|
12
|
-
name: '
|
|
12
|
+
name: 'MI'
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
day: 4,
|
|
@@ -27,4 +27,12 @@ export const days = [
|
|
|
27
27
|
day: 0,
|
|
28
28
|
name: 'D'
|
|
29
29
|
}
|
|
30
|
-
]
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
export const arraysAreEqual = (arr1, arr2) => {
|
|
33
|
+
if (arr1.length !== arr2.length) return false;
|
|
34
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
35
|
+
if (arr1[i] !== arr2[i]) return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
};
|