npm-pkg-hook 1.0.6 → 1.0.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/useCatWithProduct/index.js +2 -0
- package/src/hooks/useCatWithProduct/queries.js +3 -2
- package/src/hooks/useFormatDate/index.js +1 -1
- package/src/hooks/useSales/index.js +215 -144
- package/src/hooks/useSales/queries.js +348 -198
- package/src/hooks/useSales/useGetSale.js +9 -8
- package/src/hooks/useSales/useTotalSales.js +10 -3
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ export const useCatWithProduct = ({
|
|
|
5
5
|
max = 1,
|
|
6
6
|
min = 0,
|
|
7
7
|
search = null,
|
|
8
|
+
productName = null,
|
|
8
9
|
searchFilter= {}
|
|
9
10
|
}) => {
|
|
10
11
|
const {
|
|
@@ -22,6 +23,7 @@ export const useCatWithProduct = ({
|
|
|
22
23
|
variables:
|
|
23
24
|
{
|
|
24
25
|
search,
|
|
26
|
+
productName,
|
|
25
27
|
gender: gender,
|
|
26
28
|
min,
|
|
27
29
|
max: 400,
|
|
@@ -117,8 +117,8 @@ 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($search: String, $min: Int, $max: Int, $gender: [String], $desc: [String], $categories: [ID], ) {
|
|
121
|
-
getCatProductsWithProduct(search: $search, min: $min, max: $max, gender: $gender, desc: $desc, categories: $categories,) {
|
|
120
|
+
query getCatProductsWithProduct($search: String, $productName: String, $min: Int, $max: Int, $gender: [String], $desc: [String], $categories: [ID], ) {
|
|
121
|
+
getCatProductsWithProduct(search: $search, min: $min, productName:$productName, max: $max, gender: $gender, desc: $desc, categories: $categories,) {
|
|
122
122
|
totalCount,
|
|
123
123
|
catProductsWithProduct {
|
|
124
124
|
carProId
|
|
@@ -136,6 +136,7 @@ query getCatProductsWithProduct($search: String, $min: Int, $max: Int, $gender:
|
|
|
136
136
|
productFoodsAll {
|
|
137
137
|
pId
|
|
138
138
|
sizeId
|
|
139
|
+
|
|
139
140
|
colorId
|
|
140
141
|
carProId
|
|
141
142
|
cId
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const useFormatDate = ({
|
|
2
2
|
date,
|
|
3
3
|
local = 'ES'
|
|
4
|
-
}) => {
|
|
4
|
+
} = {}) => {
|
|
5
5
|
const dateToFormat = new Date(date ?? Date.now())
|
|
6
6
|
const fullDate = dateToFormat.toLocaleDateString(local, { year: 'numeric', month: '2-digit', day: '2-digit' })
|
|
7
7
|
const day = fullDate.split('/')[0]
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { useLazyQuery, useMutation } from "@apollo/client";
|
|
1
|
+
import { useApolloClient, useLazyQuery, useMutation } from "@apollo/client";
|
|
2
2
|
import { useCallback, useEffect, useReducer, useState } from "react";
|
|
3
3
|
import { Cookies } from "../../cookies";
|
|
4
|
-
import {
|
|
5
|
-
RandomCode,
|
|
6
|
-
getCurrentDomain,
|
|
7
|
-
updateCacheMod
|
|
8
|
-
} from "../../utils";
|
|
4
|
+
import { RandomCode, getCurrentDomain, updateCacheMod } from "../../utils";
|
|
9
5
|
import { useFormatDate } from "../useFormatDate";
|
|
10
6
|
import { useProductsFood } from "../useProductsFood";
|
|
11
7
|
import {
|
|
@@ -17,6 +13,7 @@ import { useStore } from "../useStore";
|
|
|
17
13
|
import {
|
|
18
14
|
CREATE_SHOPPING_CARD_TO_USER_STORE,
|
|
19
15
|
GET_ALL_COUNT_SALES,
|
|
16
|
+
GET_ALL_PEDIDOS,
|
|
20
17
|
GET_ALL_SALES,
|
|
21
18
|
GET_ALL_SALES_STATISTICS,
|
|
22
19
|
} from "./queries";
|
|
@@ -68,10 +65,13 @@ export const useSales = ({
|
|
|
68
65
|
const [code, setCode] = useState(null);
|
|
69
66
|
const [openCurrentSale, setOpenCurrentSale] = useState(null);
|
|
70
67
|
const { createdAt } = dataStore || {};
|
|
68
|
+
const [oneProductToComment, setOneProductToComment] = useState({});
|
|
69
|
+
const [sumExtraProducts, setSumExtraProducts] = useState(0);
|
|
71
70
|
const { yearMonthDay } = useFormatDate({ date: createdAt });
|
|
72
71
|
const [valuesDates, setValuesDates] = useState(() => {
|
|
73
72
|
return { fromDate: yearMonthDay, toDate: "" };
|
|
74
73
|
});
|
|
74
|
+
const [loadingExtraProduct, setLoadingExtraProduct] = useState(false);
|
|
75
75
|
const [dataOptional, setDataOptional] = useState([]);
|
|
76
76
|
const [dataExtra, setDataExtra] = useState([]);
|
|
77
77
|
|
|
@@ -88,7 +88,7 @@ export const useSales = ({
|
|
|
88
88
|
setOpenCurrentSale(data?.registerSalesStore?.Response.success);
|
|
89
89
|
},
|
|
90
90
|
onError: (error) => {
|
|
91
|
-
|
|
91
|
+
sendNotification({ title: error || 'Lo sentimo', description: 'ha ocurrido un error' });
|
|
92
92
|
},
|
|
93
93
|
}
|
|
94
94
|
);
|
|
@@ -165,7 +165,6 @@ export const useSales = ({
|
|
|
165
165
|
let filteredData = handleList(text);
|
|
166
166
|
setFilteredList(filteredData);
|
|
167
167
|
};
|
|
168
|
-
const [oneProductToComment, setOneProductToComment] = useState({});
|
|
169
168
|
const handleComment = (product) => {
|
|
170
169
|
if (product) {
|
|
171
170
|
setOneProductToComment(product);
|
|
@@ -213,7 +212,7 @@ export const useSales = ({
|
|
|
213
212
|
const productExist = state.PRODUCT.find((items) => {
|
|
214
213
|
return items.pId === action.id;
|
|
215
214
|
});
|
|
216
|
-
const OurProduct = productsFood
|
|
215
|
+
const OurProduct = productsFood?.find((items) => {
|
|
217
216
|
return items.pId === action.id;
|
|
218
217
|
});
|
|
219
218
|
const isFree = productExist?.free;
|
|
@@ -363,7 +362,6 @@ export const useSales = ({
|
|
|
363
362
|
* Description
|
|
364
363
|
* @returns {any}
|
|
365
364
|
* */
|
|
366
|
-
const [sumExtraProducts, setSumExtraProducts] = useState(0);
|
|
367
365
|
useEffect(() => {
|
|
368
366
|
const arr =
|
|
369
367
|
dataExtra?.length > 0
|
|
@@ -392,26 +390,38 @@ export const useSales = ({
|
|
|
392
390
|
}, [dataExtra]);
|
|
393
391
|
|
|
394
392
|
function handleUpdateAllExtra() {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
393
|
+
try {
|
|
394
|
+
if (!product?.PRODUCT?.pId) {
|
|
395
|
+
return sendNotification({
|
|
396
|
+
title: "Error",
|
|
397
|
+
description: "No se puede actualizar el producto sin pId",
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
const filteredDataOptional = dataOptional
|
|
401
|
+
.map((obj) => {
|
|
402
|
+
const filteredSubOptions = obj.ExtProductFoodsSubOptionalAll.filter(
|
|
403
|
+
(subObj) => subObj.check === true
|
|
404
|
+
);
|
|
405
|
+
// Excluya todo el objeto padre si filteredSubOptions está vacío
|
|
406
|
+
if (filteredSubOptions.length === 0) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
return { ...obj, ExtProductFoodsSubOptionalAll: filteredSubOptions };
|
|
410
|
+
})
|
|
411
|
+
.filter((obj) => obj !== null); // Elimine todos los objetos nulos del arreglo
|
|
412
|
+
const filteredDataExtra = dataExtra.filter((p) => p.quantity !== 0);
|
|
413
|
+
dispatch({
|
|
414
|
+
type: "PUT_EXTRA_PRODUCTS_AND_OPTIONAL_PRODUCT",
|
|
415
|
+
payload: product.PRODUCT.pId,
|
|
416
|
+
dataOptional: filteredDataOptional,
|
|
417
|
+
dataExtra: filteredDataExtra,
|
|
418
|
+
});
|
|
419
|
+
} catch (_error) {
|
|
420
|
+
return sendNotification({
|
|
421
|
+
title: "Error",
|
|
422
|
+
description: "No se puedo actualizar el producto",
|
|
423
|
+
});
|
|
424
|
+
}
|
|
415
425
|
}
|
|
416
426
|
|
|
417
427
|
function handleIncrementExtra({ Adicionales, index }) {
|
|
@@ -566,18 +576,14 @@ export const useSales = ({
|
|
|
566
576
|
|
|
567
577
|
const getSortedProduct = (sortData, sortBy) => {
|
|
568
578
|
if (sortBy && sortBy === "PRICE_HIGH_TO_LOW") {
|
|
569
|
-
return (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
})
|
|
573
|
-
);
|
|
579
|
+
return sortData.sort((a, b) => {
|
|
580
|
+
return b["ProPrice"] - a["ProPrice"];
|
|
581
|
+
});
|
|
574
582
|
}
|
|
575
583
|
if (sortBy && sortBy === "PRICE_LOW_TO_HIGH") {
|
|
576
|
-
return (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
})
|
|
580
|
-
);
|
|
584
|
+
return sortData.sort((a, b) => {
|
|
585
|
+
return a["ProPrice"] - b["ProPrice"];
|
|
586
|
+
});
|
|
581
587
|
}
|
|
582
588
|
return sortData;
|
|
583
589
|
};
|
|
@@ -612,27 +618,98 @@ export const useSales = ({
|
|
|
612
618
|
}
|
|
613
619
|
return "";
|
|
614
620
|
};
|
|
615
|
-
const
|
|
616
|
-
data?.PRODUCT?.length > 0
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
621
|
+
const arrayProduct =
|
|
622
|
+
data?.PRODUCT?.length > 0
|
|
623
|
+
? data?.PRODUCT?.map((product) => {
|
|
624
|
+
const filteredDataExtra =
|
|
625
|
+
product?.dataExtra?.map(({ __typename, ...rest }) => rest) ?? [];
|
|
626
|
+
const dataOptional = product?.dataOptional?.map(
|
|
627
|
+
({ __typename, ...product }) => {
|
|
628
|
+
const { ExtProductFoodsSubOptionalAll, ...rest } = product;
|
|
629
|
+
const adjustedSubOptionalAll = ExtProductFoodsSubOptionalAll?.map(
|
|
630
|
+
(subOption) => {
|
|
631
|
+
const { __typename, ...subOptionRest } = subOption;
|
|
632
|
+
return subOptionRest;
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
return {
|
|
636
|
+
...rest,
|
|
637
|
+
ExtProductFoodsSubOptionalAll: adjustedSubOptionalAll,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
const refCodePid = RandomCode(20)
|
|
642
|
+
return {
|
|
643
|
+
pId: product?.pId,
|
|
644
|
+
refCodePid: refCodePid,
|
|
645
|
+
id: values?.cliId,
|
|
646
|
+
cantProducts: parseInt(
|
|
647
|
+
product?.ProQuantity ? product?.ProQuantity : 0
|
|
648
|
+
),
|
|
649
|
+
comments: product?.comment ?? "",
|
|
650
|
+
dataOptional: dataOptional ?? [],
|
|
651
|
+
dataExtra: filteredDataExtra || [],
|
|
652
|
+
ProPrice: product.ProPrice,
|
|
653
|
+
};
|
|
654
|
+
})
|
|
655
|
+
: [];
|
|
656
|
+
const finalArrayProduct = arrayProduct.map((item) => {
|
|
657
|
+
const totalExtra = item.dataExtra.reduce(
|
|
658
|
+
(accumulator, extra) => accumulator + extra.newExtraPrice,
|
|
659
|
+
0
|
|
660
|
+
);
|
|
661
|
+
return { ...item, totalExtra };
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
let totalSale = 0;
|
|
665
|
+
function sumProPriceAndTotalExtra(data) {
|
|
666
|
+
return data.map((item) => {
|
|
667
|
+
const totalExtra = item.dataExtra.reduce((acc, curr) => {
|
|
668
|
+
const newExtraPrice = parseFloat(curr.newExtraPrice);
|
|
669
|
+
if (isNaN(newExtraPrice)) {
|
|
670
|
+
return acc;
|
|
671
|
+
}
|
|
672
|
+
return acc + newExtraPrice;
|
|
673
|
+
}, 0);
|
|
674
|
+
const total = item.ProPrice + totalExtra;
|
|
675
|
+
return { ...item, totalExtra, total };
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
useEffect(() => {
|
|
679
|
+
const dataCountTotal = sumProPriceAndTotalExtra(finalArrayProduct);
|
|
680
|
+
dataCountTotal.forEach((a) => {
|
|
681
|
+
const { total } = a || {};
|
|
682
|
+
totalSale += total;
|
|
683
|
+
setTotalProductPrice(Math.abs(totalSale));
|
|
684
|
+
});
|
|
685
|
+
if (data.PRODUCT.length === 0) {
|
|
686
|
+
setTotalProductPrice(0);
|
|
687
|
+
}
|
|
688
|
+
}, [totalProductPrice, totalSale, data, finalArrayProduct]);
|
|
689
|
+
|
|
690
|
+
const [discount, setDiscount] = useState({
|
|
691
|
+
price: totalProductPrice || 0,
|
|
692
|
+
discount: 0,
|
|
693
|
+
});
|
|
694
|
+
function applyDiscount(percentage) {
|
|
695
|
+
const validateCondition =
|
|
696
|
+
isNaN(percentage) || percentage < 0 || percentage > 100;
|
|
697
|
+
|
|
698
|
+
if (validateCondition) {
|
|
699
|
+
return sendNotification({
|
|
700
|
+
title: "Error",
|
|
701
|
+
description: "el descuento debe ser un número entre 0 y 100%",
|
|
626
702
|
});
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
703
|
+
}
|
|
704
|
+
const decimal = parseFloat(percentage) / 100;
|
|
705
|
+
const result = decimal * parseFloat(totalProductPrice);
|
|
706
|
+
setDiscount({ price: result, discount: percentage });
|
|
707
|
+
|
|
708
|
+
return { price: result, discount: percentage };
|
|
709
|
+
}
|
|
710
|
+
const totalProductsPrice = totalProductPrice;
|
|
711
|
+
const client = useApolloClient()
|
|
712
|
+
|
|
636
713
|
const handleSubmit = () => {
|
|
637
714
|
if (!values?.cliId)
|
|
638
715
|
return sendNotification({
|
|
@@ -644,38 +721,16 @@ export const useSales = ({
|
|
|
644
721
|
setCode(code);
|
|
645
722
|
return registerSalesStore({
|
|
646
723
|
variables: {
|
|
647
|
-
input:
|
|
724
|
+
input: finalArrayProduct || [],
|
|
648
725
|
id: values?.cliId,
|
|
649
726
|
pCodeRef: code,
|
|
650
727
|
change: values.change,
|
|
651
728
|
valueDelivery: parseInt(values.valueDelivery),
|
|
652
729
|
payMethodPState: data.payMethodPState,
|
|
653
730
|
pickUp: 1,
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
cache,
|
|
658
|
-
{ data: { getAllSalesStoreStatistic, getTodaySales, getAllSalesStore } }
|
|
659
|
-
) => {
|
|
660
|
-
updateCacheMod({
|
|
661
|
-
cache,
|
|
662
|
-
query: GET_ALL_SALES,
|
|
663
|
-
nameFun: "getAllSalesStore",
|
|
664
|
-
dataNew: getAllSalesStore,
|
|
665
|
-
});
|
|
666
|
-
updateCacheMod({
|
|
667
|
-
cache,
|
|
668
|
-
query: GET_ALL_COUNT_SALES,
|
|
669
|
-
nameFun: "getTodaySales",
|
|
670
|
-
dataNew: getTodaySales,
|
|
671
|
-
});
|
|
672
|
-
updateCacheMod({
|
|
673
|
-
cache,
|
|
674
|
-
query: GET_ALL_SALES_STATISTICS,
|
|
675
|
-
nameFun: "getAllSalesStoreStatistic",
|
|
676
|
-
dataNew: getAllSalesStoreStatistic
|
|
677
|
-
});
|
|
678
|
-
},
|
|
731
|
+
discount: discount.discount || 0,
|
|
732
|
+
totalProductsPrice: totalProductsPrice || 0,
|
|
733
|
+
}
|
|
679
734
|
})
|
|
680
735
|
.then((responseRegisterR) => {
|
|
681
736
|
if (responseRegisterR) {
|
|
@@ -684,6 +739,13 @@ export const useSales = ({
|
|
|
684
739
|
const { Response } = registerSalesStore || {};
|
|
685
740
|
if (Response && Response.success === true) {
|
|
686
741
|
// dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
|
|
742
|
+
client.query({
|
|
743
|
+
query: GET_ALL_COUNT_SALES,
|
|
744
|
+
fetchPolicy: 'network-only',
|
|
745
|
+
onCompleted: (data) => {
|
|
746
|
+
client.writeQuery({ query: GET_ALL_COUNT_SALES, data: { getTodaySales: data.countSales.todaySales } })
|
|
747
|
+
}
|
|
748
|
+
})
|
|
687
749
|
router.push(
|
|
688
750
|
{
|
|
689
751
|
query: {
|
|
@@ -692,7 +754,7 @@ export const useSales = ({
|
|
|
692
754
|
},
|
|
693
755
|
},
|
|
694
756
|
undefined,
|
|
695
|
-
{ shallow: true }
|
|
757
|
+
{ shallow: true }
|
|
696
758
|
);
|
|
697
759
|
// setValues({})
|
|
698
760
|
}
|
|
@@ -710,73 +772,80 @@ export const useSales = ({
|
|
|
710
772
|
let suma = 0;
|
|
711
773
|
let total = 0;
|
|
712
774
|
|
|
713
|
-
useEffect(() => {
|
|
714
|
-
data.PRODUCT.forEach((a) => {
|
|
715
|
-
const { ProPrice } = a || {};
|
|
716
|
-
suma += ProPrice;
|
|
717
|
-
setTotalProductPrice(Math.abs(suma));
|
|
718
|
-
});
|
|
719
|
-
if (data.PRODUCT.length === 0) {
|
|
720
|
-
setTotalProductPrice(0);
|
|
721
|
-
}
|
|
722
|
-
}, [totalProductPrice, suma, total, data]);
|
|
723
|
-
const [loadingExtraProduct, setLoadingExtraProduct] = useState(false);
|
|
724
|
-
|
|
725
775
|
const handleProduct = async (PRODUCT) => {
|
|
726
|
-
setLoadingExtraProduct(true)
|
|
776
|
+
setLoadingExtraProduct(true);
|
|
727
777
|
const { pId } = PRODUCT || {};
|
|
728
778
|
try {
|
|
729
779
|
const originalArray = data.PRODUCT.find((item) => {
|
|
730
780
|
return item.pId === pId;
|
|
731
781
|
});
|
|
732
782
|
// OPTIONAL
|
|
733
|
-
productFoodsOne({ variables: { pId
|
|
734
|
-
const optionalAll = await ExtProductFoodsSubOptionalAll({
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
783
|
+
productFoodsOne({ variables: { pId } });
|
|
784
|
+
const optionalAll = await ExtProductFoodsSubOptionalAll({
|
|
785
|
+
variables: { pId },
|
|
786
|
+
});
|
|
787
|
+
const optionalFetch = optionalAll.data.ExtProductFoodsOptionalAll;
|
|
788
|
+
setDataOptional(optionalFetch || []);
|
|
789
|
+
const existOptionalCookies = originalArray?.dataOptional;
|
|
790
|
+
const filteredDataOptional = existOptionalCookies?.length
|
|
791
|
+
? existOptionalCookies
|
|
792
|
+
?.map((obj) => {
|
|
793
|
+
const filteredSubOptions =
|
|
794
|
+
obj.ExtProductFoodsSubOptionalAll.filter(
|
|
795
|
+
(subObj) => subObj.check === true
|
|
796
|
+
);
|
|
797
|
+
// Excluya todo el objeto padre si filteredSubOptions está vacío
|
|
798
|
+
if (filteredSubOptions.length === 0) {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
return {
|
|
802
|
+
...obj,
|
|
803
|
+
ExtProductFoodsSubOptionalAll: filteredSubOptions,
|
|
804
|
+
};
|
|
805
|
+
})
|
|
806
|
+
.filter((obj) => obj !== null)
|
|
807
|
+
: [];
|
|
748
808
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
809
|
+
// Actualizar optionalAll.data.ExtProductFoodsSubOptionalAll con los valores actualizados de originalArray2.ExtProductFoodsSubOptionalAll
|
|
810
|
+
if (optionalFetch && filteredDataOptional) {
|
|
811
|
+
const updateOption = optionalFetch
|
|
812
|
+
.map((obj) => {
|
|
813
|
+
const matchingArray = filteredDataOptional.find(
|
|
814
|
+
(o) => o && o.opExPid === obj.opExPid
|
|
815
|
+
);
|
|
753
816
|
if (!matchingArray) {
|
|
754
817
|
return obj;
|
|
755
818
|
}
|
|
756
|
-
const extProductFoodsSubOptionalAll =
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
819
|
+
const extProductFoodsSubOptionalAll =
|
|
820
|
+
obj.ExtProductFoodsSubOptionalAll || [];
|
|
821
|
+
const updateExtProductFoodsSubOptionalAll =
|
|
822
|
+
extProductFoodsSubOptionalAll.map((subObj) => {
|
|
823
|
+
const newItem =
|
|
824
|
+
matchingArray.ExtProductFoodsSubOptionalAll.find(
|
|
825
|
+
(newItem) =>
|
|
826
|
+
newItem && newItem.opSubExPid === subObj.opSubExPid
|
|
827
|
+
);
|
|
828
|
+
if (newItem) {
|
|
829
|
+
return {
|
|
830
|
+
...subObj,
|
|
831
|
+
check: true,
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
return subObj;
|
|
835
|
+
});
|
|
769
836
|
return {
|
|
770
837
|
...obj,
|
|
771
|
-
ExtProductFoodsSubOptionalAll:
|
|
838
|
+
ExtProductFoodsSubOptionalAll:
|
|
839
|
+
updateExtProductFoodsSubOptionalAll,
|
|
772
840
|
};
|
|
773
|
-
})
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
841
|
+
})
|
|
842
|
+
.filter((obj) => obj);
|
|
843
|
+
if (existOptionalCookies) {
|
|
844
|
+
setDataOptional(updateOption || []);
|
|
845
|
+
} else {
|
|
846
|
+
setDataOptional(optionalAll.data.ExtProductFoodsOptionalAll || []);
|
|
779
847
|
}
|
|
848
|
+
}
|
|
780
849
|
// NO OPTIONAL
|
|
781
850
|
const extProduct = await ExtProductFoodsAll({ variables: { pId } });
|
|
782
851
|
let finalData;
|
|
@@ -803,10 +872,10 @@ export const useSales = ({
|
|
|
803
872
|
PRODUCT,
|
|
804
873
|
};
|
|
805
874
|
});
|
|
806
|
-
setLoadingExtraProduct(false)
|
|
875
|
+
setLoadingExtraProduct(false);
|
|
807
876
|
} catch (error) {
|
|
808
|
-
setLoadingExtraProduct(false)
|
|
809
|
-
|
|
877
|
+
setLoadingExtraProduct(false);
|
|
878
|
+
sendNotification({ description: error || "Lo sentimos, ocurrió un error" });
|
|
810
879
|
}
|
|
811
880
|
};
|
|
812
881
|
const handleCleanFilter = () => {
|
|
@@ -814,7 +883,7 @@ export const useSales = ({
|
|
|
814
883
|
setValues({});
|
|
815
884
|
setValuesDates({ fromDate: yearMonthDay, toDate: "" });
|
|
816
885
|
};
|
|
817
|
-
const disabledModalItems = dataOptional?.length > 0 || dataExtra?.length > 0
|
|
886
|
+
const disabledModalItems = dataOptional?.length > 0 || dataExtra?.length > 0;
|
|
818
887
|
return {
|
|
819
888
|
// loading: loading || loadingSale,
|
|
820
889
|
loading: false,
|
|
@@ -830,7 +899,7 @@ export const useSales = ({
|
|
|
830
899
|
data,
|
|
831
900
|
openCommentModal,
|
|
832
901
|
inputValue,
|
|
833
|
-
|
|
902
|
+
arrayProduct,
|
|
834
903
|
delivery,
|
|
835
904
|
valuesDates,
|
|
836
905
|
print,
|
|
@@ -848,6 +917,7 @@ export const useSales = ({
|
|
|
848
917
|
dataOptional: dataOptional || [],
|
|
849
918
|
dataExtra: dataExtra || [],
|
|
850
919
|
fetchMore,
|
|
920
|
+
discount,
|
|
851
921
|
handleUpdateAllExtra,
|
|
852
922
|
dispatch,
|
|
853
923
|
setArrayCategory,
|
|
@@ -859,6 +929,7 @@ export const useSales = ({
|
|
|
859
929
|
setOpenCurrentSale,
|
|
860
930
|
onChangeInput,
|
|
861
931
|
handleRemoveValue,
|
|
932
|
+
applyDiscount,
|
|
862
933
|
setDelivery,
|
|
863
934
|
setValues,
|
|
864
935
|
setShowMore,
|
|
@@ -1,34 +1,61 @@
|
|
|
1
|
-
import { gql } from
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
export const GET_ALL_SALES = gql`
|
|
4
|
-
query getAllSalesStore(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
query getAllSalesStore(
|
|
5
|
+
$idStore: ID
|
|
6
|
+
$search: String
|
|
7
|
+
$min: Int
|
|
8
|
+
$max: Int
|
|
9
|
+
$fromDate: DateTime
|
|
10
|
+
$toDate: DateTime
|
|
11
|
+
) {
|
|
12
|
+
getAllSalesStore(
|
|
13
|
+
idStore: $idStore
|
|
14
|
+
search: $search
|
|
15
|
+
min: $min
|
|
16
|
+
max: $max
|
|
17
|
+
toDate: $toDate
|
|
18
|
+
fromDate: $fromDate
|
|
19
|
+
) {
|
|
20
|
+
totalProductsPrice
|
|
21
|
+
pDatCre
|
|
22
|
+
}
|
|
9
23
|
}
|
|
10
|
-
|
|
11
|
-
`
|
|
24
|
+
`;
|
|
12
25
|
|
|
13
26
|
export const GET_ALL_COUNT_SALES = gql`
|
|
14
|
-
query getTodaySales {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
27
|
+
query getTodaySales {
|
|
28
|
+
getTodaySales
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
18
31
|
export const GET_ALL_SALES_STATISTICS = gql`
|
|
19
|
-
query getAllSalesStoreStatistic(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
query getAllSalesStoreStatistic(
|
|
33
|
+
$idStore: ID
|
|
34
|
+
$search: String
|
|
35
|
+
$min: Int
|
|
36
|
+
$max: Int
|
|
37
|
+
$fromDate: DateTime
|
|
38
|
+
$toDate: DateTime
|
|
39
|
+
) {
|
|
40
|
+
getAllSalesStoreStatistic(
|
|
41
|
+
idStore: $idStore
|
|
42
|
+
search: $search
|
|
43
|
+
min: $min
|
|
44
|
+
max: $max
|
|
45
|
+
toDate: $toDate
|
|
46
|
+
fromDate: $fromDate
|
|
47
|
+
) {
|
|
48
|
+
pdpId
|
|
49
|
+
idStore
|
|
50
|
+
pCodeRef
|
|
51
|
+
payMethodPState
|
|
52
|
+
pPRecoger
|
|
53
|
+
totalProductsPrice
|
|
54
|
+
pSState
|
|
55
|
+
pDatCre
|
|
56
|
+
locationUser
|
|
57
|
+
pDatMod
|
|
58
|
+
getAllPedidoStore {
|
|
32
59
|
pdpId
|
|
33
60
|
pId
|
|
34
61
|
idStore
|
|
@@ -44,146 +71,166 @@ query getAllSalesStoreStatistic($idStore: ID,$search: String, $min: Int, $max: I
|
|
|
44
71
|
comments
|
|
45
72
|
cantProducts
|
|
46
73
|
pId
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
productFood {
|
|
75
|
+
pId
|
|
76
|
+
carProId
|
|
77
|
+
colorId
|
|
78
|
+
idStore
|
|
79
|
+
pName
|
|
80
|
+
ProPrice
|
|
81
|
+
ProDescuento
|
|
82
|
+
ProDescription
|
|
83
|
+
ValueDelivery
|
|
84
|
+
ProImage
|
|
85
|
+
ProStar
|
|
86
|
+
pState
|
|
87
|
+
pDatCre
|
|
88
|
+
pDatMod
|
|
89
|
+
}
|
|
62
90
|
}
|
|
63
91
|
}
|
|
64
92
|
}
|
|
65
93
|
}
|
|
66
|
-
|
|
67
|
-
`
|
|
94
|
+
`;
|
|
68
95
|
|
|
69
96
|
export const GET_ONE_SALES = gql`
|
|
70
|
-
query getOnePedidoStore($pCodeRef: String) {
|
|
71
|
-
|
|
72
|
-
pdpId
|
|
73
|
-
pCodeRef
|
|
74
|
-
idStore
|
|
75
|
-
pPDate
|
|
76
|
-
channel
|
|
77
|
-
pSState
|
|
78
|
-
pDatCre
|
|
79
|
-
pDatMod
|
|
80
|
-
pPRecoger
|
|
81
|
-
payMethodPState
|
|
82
|
-
pdpId
|
|
83
|
-
totalProductsPrice
|
|
84
|
-
locationUser
|
|
85
|
-
getAllPedidoStore {
|
|
97
|
+
query getOnePedidoStore($pCodeRef: String) {
|
|
98
|
+
getOnePedidoStore(pCodeRef: $pCodeRef) {
|
|
86
99
|
pdpId
|
|
87
|
-
idStore
|
|
88
100
|
pCodeRef
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
idStore
|
|
102
|
+
pPDate
|
|
103
|
+
channel
|
|
104
|
+
pSState
|
|
105
|
+
pDatCre
|
|
106
|
+
pDatMod
|
|
107
|
+
pPRecoger
|
|
108
|
+
payMethodPState
|
|
109
|
+
pdpId
|
|
110
|
+
totalProductsPrice
|
|
111
|
+
locationUser
|
|
112
|
+
getAllPedidoStore {
|
|
113
|
+
pdpId
|
|
114
|
+
idStore
|
|
115
|
+
pCodeRef
|
|
91
116
|
ShoppingCard
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
getAllShoppingCard {
|
|
118
|
+
ShoppingCard
|
|
119
|
+
cantProducts
|
|
120
|
+
subProductsId
|
|
121
|
+
comments
|
|
122
|
+
pId
|
|
123
|
+
productFood {
|
|
124
|
+
pId
|
|
125
|
+
carProId
|
|
126
|
+
colorId
|
|
127
|
+
idStore
|
|
128
|
+
pName
|
|
129
|
+
ProPrice
|
|
130
|
+
ProDescuento
|
|
131
|
+
ProDescription
|
|
132
|
+
ValueDelivery
|
|
133
|
+
ProImage
|
|
134
|
+
ProStar
|
|
135
|
+
pState
|
|
136
|
+
pDatCre
|
|
137
|
+
pDatMod
|
|
138
|
+
}
|
|
111
139
|
}
|
|
112
140
|
}
|
|
113
141
|
}
|
|
114
142
|
}
|
|
115
|
-
|
|
116
|
-
`
|
|
117
|
-
|
|
143
|
+
`;
|
|
118
144
|
|
|
119
145
|
export const CREATE_CLIENTS = gql`
|
|
120
|
-
mutation createClients
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
mutation createClients($input: IClients) {
|
|
147
|
+
createClients(input: $input) {
|
|
148
|
+
cliId
|
|
149
|
+
idStore
|
|
150
|
+
idUser
|
|
151
|
+
clState
|
|
152
|
+
ClientAddress
|
|
153
|
+
clientNumber
|
|
154
|
+
ccClient
|
|
155
|
+
gender
|
|
156
|
+
clientLastName
|
|
157
|
+
clientName
|
|
158
|
+
createAt
|
|
159
|
+
updateAt
|
|
160
|
+
}
|
|
134
161
|
}
|
|
135
|
-
|
|
136
|
-
`
|
|
162
|
+
`;
|
|
137
163
|
export const DELETE_ONE_CLIENTS = gql`
|
|
138
|
-
mutation deleteClient($cliId: ID, $clState: Int!) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
164
|
+
mutation deleteClient($cliId: ID, $clState: Int!) {
|
|
165
|
+
deleteClient(cliId: $cliId, clState: $clState) {
|
|
166
|
+
success
|
|
167
|
+
message
|
|
168
|
+
}
|
|
142
169
|
}
|
|
143
|
-
|
|
144
|
-
`
|
|
170
|
+
`;
|
|
145
171
|
export const GET_ALL_CLIENTS = gql`
|
|
146
|
-
query getAllClients(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
172
|
+
query getAllClients(
|
|
173
|
+
$idStore: ID
|
|
174
|
+
$cId: ID
|
|
175
|
+
$dId: ID
|
|
176
|
+
$ctId: ID
|
|
177
|
+
$search: String
|
|
178
|
+
$min: Int
|
|
179
|
+
$max: Int
|
|
180
|
+
$fromDate: DateTime
|
|
181
|
+
$toDate: DateTime
|
|
182
|
+
) {
|
|
183
|
+
getAllClients(
|
|
184
|
+
idStore: $idStore
|
|
185
|
+
cId: $cId
|
|
186
|
+
dId: $dId
|
|
187
|
+
ctId: $ctId
|
|
188
|
+
search: $search
|
|
189
|
+
min: $min
|
|
190
|
+
max: $max
|
|
191
|
+
fromDate: $fromDate
|
|
192
|
+
toDate: $toDate
|
|
193
|
+
) {
|
|
194
|
+
cliId
|
|
195
|
+
idStore
|
|
196
|
+
gender
|
|
197
|
+
# idUser
|
|
198
|
+
clState
|
|
199
|
+
clientNumber
|
|
200
|
+
ccClient
|
|
201
|
+
clientLastName
|
|
202
|
+
clientName
|
|
203
|
+
ClientAddress
|
|
204
|
+
createAt
|
|
205
|
+
updateAt
|
|
206
|
+
}
|
|
161
207
|
}
|
|
162
|
-
|
|
163
|
-
`
|
|
208
|
+
`;
|
|
164
209
|
export const GET_ONE_CLIENT = gql`
|
|
165
|
-
query getOneClients($cliId: ID) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
210
|
+
query getOneClients($cliId: ID) {
|
|
211
|
+
getOneClients(cliId: $cliId) {
|
|
212
|
+
cliId
|
|
213
|
+
idStore
|
|
214
|
+
idUser
|
|
215
|
+
clState
|
|
216
|
+
clientNumber
|
|
217
|
+
ClientAddress
|
|
218
|
+
gender
|
|
219
|
+
ccClient
|
|
220
|
+
clientLastName
|
|
221
|
+
clientName
|
|
222
|
+
createAt
|
|
223
|
+
updateAt
|
|
224
|
+
}
|
|
180
225
|
}
|
|
181
|
-
|
|
182
|
-
`
|
|
226
|
+
`;
|
|
183
227
|
|
|
184
228
|
export const CREATE_SHOPPING_CARD = gql`
|
|
185
|
-
mutation
|
|
186
|
-
|
|
229
|
+
mutation registerShoppingCard(
|
|
230
|
+
$input: IShoppingCard
|
|
231
|
+
$idSubArray: IID_SUB_ITEMS
|
|
232
|
+
) {
|
|
233
|
+
registerShoppingCard(input: $input, idSubArray: $idSubArray) {
|
|
187
234
|
ShoppingCard
|
|
188
235
|
id
|
|
189
236
|
pId
|
|
@@ -201,46 +248,179 @@ mutation registerShoppingCard($input: IShoppingCard, $idSubArray: IID_SUB_ITEMS
|
|
|
201
248
|
cantProducts
|
|
202
249
|
comments
|
|
203
250
|
# idSubArray
|
|
251
|
+
}
|
|
204
252
|
}
|
|
205
|
-
|
|
206
|
-
`
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
getOnePedidoStore(pCodeRef: $pCodeRef) {
|
|
210
|
-
pdpId
|
|
211
|
-
pCodeRef
|
|
212
|
-
idStore
|
|
213
|
-
pPDate
|
|
214
|
-
channel
|
|
215
|
-
channel
|
|
216
|
-
change
|
|
217
|
-
pSState
|
|
218
|
-
pDatCre
|
|
219
|
-
pDatMod
|
|
220
|
-
pPRecoger
|
|
221
|
-
payMethodPState
|
|
222
|
-
pdpId
|
|
223
|
-
totalProductsPrice
|
|
224
|
-
locationUser
|
|
225
|
-
getAllPedidoStore {
|
|
253
|
+
`;
|
|
254
|
+
export const GET_ONE_SALE = gql`
|
|
255
|
+
query getOnePedidoStore($pCodeRef: String) {
|
|
256
|
+
getOnePedidoStore(pCodeRef: $pCodeRef) {
|
|
226
257
|
pdpId
|
|
227
|
-
idStore
|
|
228
258
|
pCodeRef
|
|
229
|
-
|
|
230
|
-
|
|
259
|
+
idStore
|
|
260
|
+
pPDate
|
|
261
|
+
channel
|
|
262
|
+
pSState
|
|
263
|
+
pDatCre
|
|
264
|
+
pDatMod
|
|
265
|
+
pPRecoger
|
|
266
|
+
payMethodPState
|
|
267
|
+
pdpId
|
|
268
|
+
totalProductsPrice
|
|
269
|
+
locationUser
|
|
270
|
+
getAllPedidoStore {
|
|
271
|
+
pdpId
|
|
272
|
+
idStore
|
|
273
|
+
pCodeRef
|
|
274
|
+
ShoppingCard
|
|
275
|
+
getAllShoppingCard {
|
|
276
|
+
ShoppingCard
|
|
277
|
+
cantProducts
|
|
278
|
+
refCodePid
|
|
279
|
+
subProductsId
|
|
280
|
+
comments
|
|
281
|
+
pId
|
|
282
|
+
salesExtProductFoodOptional {
|
|
283
|
+
pId
|
|
284
|
+
opExPid
|
|
285
|
+
OptionalProName
|
|
286
|
+
state
|
|
287
|
+
code
|
|
288
|
+
required
|
|
289
|
+
numbersOptionalOnly
|
|
290
|
+
pDatCre
|
|
291
|
+
pDatMod
|
|
292
|
+
saleExtProductFoodsSubOptionalAll {
|
|
293
|
+
pId
|
|
294
|
+
opExPid
|
|
295
|
+
idStore
|
|
296
|
+
opSubExPid
|
|
297
|
+
OptionalSubProName
|
|
298
|
+
exCodeOptionExtra
|
|
299
|
+
exCode
|
|
300
|
+
state
|
|
301
|
+
pDatCre
|
|
302
|
+
pDatMod
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
ExtProductFoodsAll {
|
|
306
|
+
pId
|
|
307
|
+
exPid
|
|
308
|
+
exState
|
|
309
|
+
extraName
|
|
310
|
+
extraPrice
|
|
311
|
+
newExtraPrice
|
|
312
|
+
quantity
|
|
313
|
+
state
|
|
314
|
+
pDatCre
|
|
315
|
+
pDatMod
|
|
316
|
+
}
|
|
317
|
+
productFood {
|
|
318
|
+
pId
|
|
319
|
+
carProId
|
|
320
|
+
colorId
|
|
321
|
+
idStore
|
|
322
|
+
pName
|
|
323
|
+
ProPrice
|
|
324
|
+
ProDescuento
|
|
325
|
+
ProDescription
|
|
326
|
+
ValueDelivery
|
|
327
|
+
ProImage
|
|
328
|
+
ProStar
|
|
329
|
+
pState
|
|
330
|
+
pDatCre
|
|
331
|
+
pDatMod
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
`;
|
|
338
|
+
|
|
339
|
+
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
340
|
+
mutation registerSalesStore(
|
|
341
|
+
$input: [IShoppingCard]
|
|
342
|
+
$id: ID
|
|
343
|
+
$idStore: ID
|
|
344
|
+
$pCodeRef: String
|
|
345
|
+
$discount: Int
|
|
346
|
+
$change: String
|
|
347
|
+
$valueDelivery: Float
|
|
348
|
+
$payMethodPState: Int
|
|
349
|
+
$pickUp: Int
|
|
350
|
+
$totalProductsPrice: Float
|
|
351
|
+
$idSubArray: IID_SUB_ITEMS
|
|
352
|
+
) {
|
|
353
|
+
registerSalesStore(
|
|
354
|
+
input: $input
|
|
355
|
+
id: $id
|
|
356
|
+
idStore: $idStore
|
|
357
|
+
pCodeRef: $pCodeRef
|
|
358
|
+
change: $change
|
|
359
|
+
discount: $discount
|
|
360
|
+
valueDelivery: $valueDelivery
|
|
361
|
+
payMethodPState: $payMethodPState
|
|
362
|
+
pickUp: $pickUp
|
|
363
|
+
totalProductsPrice: $totalProductsPrice
|
|
364
|
+
idSubArray: $idSubArray
|
|
365
|
+
) {
|
|
366
|
+
ShoppingCard {
|
|
367
|
+
ShoppingCard
|
|
368
|
+
id
|
|
369
|
+
pId
|
|
231
370
|
subProductsId
|
|
232
371
|
ShoppingCardRefCode
|
|
233
372
|
uuid
|
|
234
373
|
discountCardProduct
|
|
235
374
|
idUser
|
|
375
|
+
cName
|
|
236
376
|
idStore
|
|
377
|
+
cState
|
|
378
|
+
cDatCre
|
|
379
|
+
cDatMod
|
|
237
380
|
csDescription
|
|
238
|
-
ShoppingCard
|
|
239
381
|
cantProducts
|
|
240
|
-
subProductsId
|
|
241
382
|
comments
|
|
383
|
+
}
|
|
384
|
+
Response {
|
|
385
|
+
success
|
|
386
|
+
message
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
`;
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
export const GET_ALL_PEDIDOS = gql`
|
|
394
|
+
query getAllPedidoStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int, $statusOrder: Int) {
|
|
395
|
+
getAllPedidoStoreFinal(idStore: $idStore, search: $search, min: $min, max: $max, statusOrder: $statusOrder) {
|
|
396
|
+
pdpId
|
|
397
|
+
idStore
|
|
398
|
+
pCodeRef
|
|
399
|
+
payMethodPState
|
|
400
|
+
pPRecoger
|
|
401
|
+
totalProductsPrice
|
|
402
|
+
pSState
|
|
403
|
+
pDatCre
|
|
404
|
+
channel
|
|
405
|
+
locationUser
|
|
406
|
+
pDatMod
|
|
407
|
+
getAllPedidoStore{
|
|
408
|
+
pdpId
|
|
242
409
|
pId
|
|
243
|
-
|
|
410
|
+
idStore
|
|
411
|
+
ShoppingCard
|
|
412
|
+
pCodeRef
|
|
413
|
+
pPStateP
|
|
414
|
+
payMethodPState
|
|
415
|
+
pPRecoger
|
|
416
|
+
pDatCre
|
|
417
|
+
pDatMod
|
|
418
|
+
getAllShoppingCard {
|
|
419
|
+
ShoppingCard
|
|
420
|
+
comments
|
|
421
|
+
cantProducts
|
|
422
|
+
pId
|
|
423
|
+
productFood{
|
|
244
424
|
pId
|
|
245
425
|
carProId
|
|
246
426
|
colorId
|
|
@@ -260,34 +440,4 @@ query getOnePedidoStore($pCodeRef: String) {
|
|
|
260
440
|
}
|
|
261
441
|
}
|
|
262
442
|
}
|
|
263
|
-
`
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
267
|
-
mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pCodeRef: String, $change: String, $valueDelivery: Float, $payMethodPState: Int, $pickUp: Int, $totalProductsPrice: Float, $idSubArray: IID_SUB_ITEMS){
|
|
268
|
-
registerSalesStore(input: $input, id: $id, idStore: $idStore, pCodeRef: $pCodeRef, change: $change, valueDelivery: $valueDelivery, payMethodPState: $payMethodPState, pickUp: $pickUp, totalProductsPrice: $totalProductsPrice, idSubArray: $idSubArray){
|
|
269
|
-
ShoppingCard {
|
|
270
|
-
ShoppingCard
|
|
271
|
-
id
|
|
272
|
-
pId
|
|
273
|
-
subProductsId
|
|
274
|
-
ShoppingCardRefCode
|
|
275
|
-
uuid
|
|
276
|
-
discountCardProduct
|
|
277
|
-
idUser
|
|
278
|
-
cName
|
|
279
|
-
idStore
|
|
280
|
-
cState
|
|
281
|
-
cDatCre
|
|
282
|
-
cDatMod
|
|
283
|
-
csDescription
|
|
284
|
-
cantProducts
|
|
285
|
-
comments
|
|
286
|
-
}
|
|
287
|
-
Response {
|
|
288
|
-
success
|
|
289
|
-
message
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
443
|
`
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useLazyQuery } from '@apollo/client'
|
|
2
2
|
import { GET_ONE_SALE } from './queries'
|
|
3
|
-
export const useGetSale = () => {
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export const useGetSale = () => {
|
|
5
|
+
const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
|
|
6
|
+
return {
|
|
7
|
+
data: data?.getOnePedidoStore, // actualizado aquí
|
|
8
|
+
loading,
|
|
9
|
+
error,
|
|
10
|
+
called,
|
|
11
|
+
getOnePedidoStore
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
|
-
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
1
|
+
import { useApolloClient, useQuery } from '@apollo/client'
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
import { GET_ALL_COUNT_SALES } from './queries'
|
|
4
|
-
|
|
4
|
+
export * from './queries'
|
|
5
5
|
export const useTotalSales = () => {
|
|
6
6
|
const [count, setCount] = useState(0)
|
|
7
|
+
const client = useApolloClient();
|
|
8
|
+
|
|
7
9
|
const { loading, error } = useQuery(GET_ALL_COUNT_SALES, {
|
|
8
10
|
onCompleted: (data) => {
|
|
9
|
-
|
|
11
|
+
if (data) {
|
|
12
|
+
client.writeQuery({ query: GET_ALL_COUNT_SALES, data }); // Almacena la respuesta en la cache
|
|
13
|
+
}
|
|
14
|
+
if (data?.getTodaySales) {
|
|
15
|
+
setCount(data?.getTodaySales || 0)
|
|
16
|
+
}
|
|
10
17
|
},
|
|
11
18
|
fetchPolicy: 'cache-and-network',
|
|
12
19
|
notifyOnNetworkStatusChange: true,
|