npm-pkg-hook 1.1.3 → 1.1.4
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 +132 -132
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +8 -0
- package/next.config.js +1 -0
- package/package.json +43 -46
- package/src/config/client/errors.js +1 -2
- package/src/hooks/index.js +20 -25
- package/src/hooks/useAnimationText/index.jsx +13 -11
- package/src/hooks/useCatWithProduct/index.js +4 -37
- package/src/hooks/useCatWithProduct/queries.js +16 -0
- package/src/hooks/useChartData/index.js +170 -1
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +14 -9
- package/src/hooks/useCheckbox/index.js +2 -5
- package/src/hooks/useClients/index.js +8 -17
- package/src/hooks/useCreateProduct/index.js +64 -94
- package/src/hooks/useDrag/index.js +1 -0
- package/src/hooks/useEmployee/index.js +8 -11
- package/src/hooks/useFormTools/index.js +1 -1
- package/src/hooks/useFullScreenMode/index.js +8 -8
- package/src/hooks/useGoogleLogin/index.js +161 -0
- package/src/hooks/useGoogleLogin/loadScript.js +15 -0
- package/src/hooks/useGoogleLogin/removeScript.js +7 -0
- package/src/hooks/useHover/index.js +1 -1
- package/src/hooks/useImagesStore/index.js +144 -176
- package/src/hooks/useImagesStore/queries.js +28 -1
- package/src/hooks/useKeypress/index.js +1 -7
- package/src/hooks/useLogout/index.js +27 -22
- package/src/hooks/useManageQueryParams/index.js +1 -1
- package/src/hooks/useProductsFood/queriesStore.js +16 -3
- package/src/hooks/useReport/index.js +30 -26
- package/src/hooks/useReport/queries.js +32 -47
- package/src/hooks/useSales/index.js +21 -52
- package/src/hooks/useSales/queries.js +38 -48
- package/src/hooks/useSales/useGetSale.js +2 -16
- package/src/hooks/useSchedule/index.jsx +23 -0
- package/src/hooks/useStoreContacts/index.js +1 -5
- package/src/hooks/useUpdateExistingOrders/index.js +8 -8
- package/src/hooks/useUser/index.js +2 -2
- package/src/hooks/useUser/queries.js +40 -40
- package/src/hooks/useWindowSize/index.js +1 -1
- package/src/index.jsx +1 -2
- package/src/security/index.js +0 -0
|
@@ -420,7 +420,6 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
`;
|
|
423
|
-
|
|
424
423
|
export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
|
|
425
424
|
mutation updateExtProductFoodsSubOptional(
|
|
426
425
|
$input: InputExtProductFoodSubOptional
|
|
@@ -702,6 +701,14 @@ export const GET_BANNER_PROMO_DASHBOARD = gql`
|
|
|
702
701
|
}
|
|
703
702
|
`;
|
|
704
703
|
|
|
704
|
+
export const CREATE_STORE_CALENDAR = gql`
|
|
705
|
+
mutation setStoreSchedule($input: ITstoreSchedule!) {
|
|
706
|
+
setStoreSchedule(input: $input) {
|
|
707
|
+
message
|
|
708
|
+
success
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
`;
|
|
705
712
|
export const DELETE_ONE_CAT_PRODUCTS = gql`
|
|
706
713
|
mutation deleteCatOfProducts($idPc: ID!, $pState: Int) {
|
|
707
714
|
deleteCatOfProducts(idPc: $idPc, pState: $pState) {
|
|
@@ -734,8 +741,14 @@ export const EDIT_EXTRA_PRODUCTS = gql`
|
|
|
734
741
|
}
|
|
735
742
|
}
|
|
736
743
|
`;
|
|
737
|
-
|
|
738
|
-
|
|
744
|
+
export const DELETE_CAT_EXTRA_PRODUCTS = gql`
|
|
745
|
+
mutation DeleteExtProductFoodsOptional($opExPid: ID, $state: Int) {
|
|
746
|
+
DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state) {
|
|
747
|
+
success
|
|
748
|
+
message
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
`;
|
|
739
752
|
export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
|
|
740
753
|
mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int) {
|
|
741
754
|
DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useQuery, useLazyQuery } from '@apollo/client'
|
|
2
|
-
import { GET_ALL_SALES, GET_ALL_TOTAL_SALES } from './queries'
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
2
|
+
import { GET_ALL_SALES, GET_ALL_TOTAL_SALES } from './queries';
|
|
3
3
|
|
|
4
4
|
export const useReport = ({
|
|
5
5
|
fromDate = '',
|
|
@@ -9,36 +9,40 @@ export const useReport = ({
|
|
|
9
9
|
toDate = '',
|
|
10
10
|
lazyQuery = false
|
|
11
11
|
}) => {
|
|
12
|
-
const [getAllSalesStore, { data: lazyDataSales, loading: lazyLoading }] = useLazyQuery(GET_ALL_SALES)
|
|
12
|
+
const [getAllSalesStore, { data: lazyDataSales, loading: lazyLoading }] = useLazyQuery(GET_ALL_SALES);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Combine both queries to reduce separate requests
|
|
15
|
+
const { data, fetchMore, loading } = useQuery(GET_ALL_SALES, {
|
|
16
|
+
fetchPolicy: lazyQuery ? 'cache-and-network' : 'network-only',
|
|
16
17
|
skip: lazyQuery,
|
|
17
18
|
variables: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
min: 0,
|
|
20
|
+
fromDate,
|
|
21
|
+
channel,
|
|
22
|
+
search,
|
|
23
|
+
toDate,
|
|
24
|
+
max: more
|
|
24
25
|
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Get total sales in the same query
|
|
29
|
+
const { data: totalSalesData } = useQuery(GET_ALL_TOTAL_SALES, {
|
|
28
30
|
variables: {
|
|
29
31
|
fromDate,
|
|
30
|
-
toDate
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
toDate
|
|
33
|
+
},
|
|
34
|
+
skip: !data || data?.getAllSalesStore?.length === 0 // Skip if main query hasn't loaded or has no data
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const totalSales = totalSalesData?.getAllSalesStoreTotal ?? {};
|
|
34
38
|
|
|
35
39
|
return {
|
|
36
|
-
getAllSalesStore,
|
|
37
|
-
data: data,
|
|
38
|
-
loading: lazyLoading || loading,
|
|
39
|
-
totalSales: totalSales
|
|
40
|
-
restaurant: totalSales
|
|
41
|
-
delivery: totalSales
|
|
40
|
+
getAllSalesStore: lazyQuery ? getAllSalesStore : () => { return }, // Return function only if in lazy mode
|
|
41
|
+
data: lazyQuery ? data || lazyDataSales : data, // Use data from lazy query if available
|
|
42
|
+
loading: lazyQuery ? lazyLoading || loading : loading,
|
|
43
|
+
totalSales: totalSales.TOTAL || 0,
|
|
44
|
+
restaurant: totalSales.restaurant || 0,
|
|
45
|
+
delivery: totalSales.delivery || 0,
|
|
42
46
|
fetchMore
|
|
43
|
-
}
|
|
44
|
-
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { gql } from '@apollo/client'
|
|
2
2
|
|
|
3
3
|
export const GET_ALL_SALES = gql`
|
|
4
|
-
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime
|
|
5
|
-
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate
|
|
4
|
+
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
5
|
+
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
6
6
|
totalProductsPrice
|
|
7
|
+
channel
|
|
7
8
|
pDatCre
|
|
8
9
|
pCodeRef
|
|
9
|
-
change
|
|
10
|
-
channel
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
`
|
|
@@ -22,33 +21,19 @@ query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $
|
|
|
22
21
|
}
|
|
23
22
|
`
|
|
24
23
|
export const GET_ALL_SALES_STATISTICS = gql`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
toDate: $toDate
|
|
39
|
-
fromDate: $fromDate
|
|
40
|
-
) {
|
|
41
|
-
pdpId
|
|
42
|
-
idStore
|
|
43
|
-
pCodeRef
|
|
44
|
-
payMethodPState
|
|
45
|
-
pPRecoger
|
|
46
|
-
totalProductsPrice
|
|
47
|
-
pSState
|
|
48
|
-
pDatCre
|
|
49
|
-
locationUser
|
|
50
|
-
pDatMod
|
|
51
|
-
getAllPedidoStore {
|
|
24
|
+
query getAllSalesStoreStatistic($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
25
|
+
getAllSalesStoreStatistic(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
26
|
+
pdpId
|
|
27
|
+
idStore
|
|
28
|
+
pCodeRef
|
|
29
|
+
payMethodPState
|
|
30
|
+
pPRecoger
|
|
31
|
+
totalProductsPrice
|
|
32
|
+
pSState
|
|
33
|
+
pDatCre
|
|
34
|
+
locationUser
|
|
35
|
+
pDatMod
|
|
36
|
+
getAllPedidoStore{
|
|
52
37
|
pdpId
|
|
53
38
|
pId
|
|
54
39
|
idStore
|
|
@@ -64,26 +49,26 @@ export const GET_ALL_SALES_STATISTICS = gql`
|
|
|
64
49
|
comments
|
|
65
50
|
cantProducts
|
|
66
51
|
pId
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
52
|
+
productFood{
|
|
53
|
+
pId
|
|
54
|
+
carProId
|
|
55
|
+
colorId
|
|
56
|
+
idStore
|
|
57
|
+
pName
|
|
58
|
+
ProPrice
|
|
59
|
+
ProDescuento
|
|
60
|
+
ProDescription
|
|
61
|
+
ValueDelivery
|
|
62
|
+
ProImage
|
|
63
|
+
ProStar
|
|
64
|
+
pState
|
|
65
|
+
pDatCre
|
|
66
|
+
pDatMod
|
|
83
67
|
}
|
|
84
68
|
}
|
|
85
69
|
}
|
|
86
70
|
}
|
|
71
|
+
}
|
|
87
72
|
`
|
|
88
73
|
|
|
89
74
|
export const GET_ONE_SALES = gql`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
from,
|
|
2
3
|
useApolloClient,
|
|
3
4
|
useLazyQuery,
|
|
4
5
|
useMutation
|
|
@@ -20,11 +21,12 @@ import {
|
|
|
20
21
|
GET_ONE_PRODUCTS_FOOD,
|
|
21
22
|
} from "../useProductsFood/queriesStore";
|
|
22
23
|
import { useStore } from "../useStore";
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
import {
|
|
25
|
+
CREATE_SHOPPING_CARD_TO_USER_STORE,
|
|
26
|
+
GET_ALL_COUNT_SALES
|
|
27
|
+
} from "./queries";
|
|
27
28
|
export * from './useGetAllSales'
|
|
29
|
+
export { GET_ALL_COUNT_SALES } from './queries'
|
|
28
30
|
|
|
29
31
|
const initialState = {
|
|
30
32
|
PRODUCT: [],
|
|
@@ -49,10 +51,9 @@ const initializer = (initialValue = initialState) => {
|
|
|
49
51
|
|
|
50
52
|
export const useSales = ({
|
|
51
53
|
disabled,
|
|
54
|
+
sendNotification,
|
|
52
55
|
router,
|
|
53
|
-
|
|
54
|
-
setAlertBox = () => { return },
|
|
55
|
-
setSalesOpen = () => { return },
|
|
56
|
+
setAlertBox,
|
|
56
57
|
}) => {
|
|
57
58
|
const domain = getCurrentDomain();
|
|
58
59
|
const [loadingSale, setLoadingSale] = useState(false);
|
|
@@ -83,31 +84,22 @@ export const useSales = ({
|
|
|
83
84
|
const [loadingExtraProduct, setLoadingExtraProduct] = useState(false);
|
|
84
85
|
const [dataOptional, setDataOptional] = useState([]);
|
|
85
86
|
const [dataExtra, setDataExtra] = useState([]);
|
|
86
|
-
const [onClickLogout] = useLogout({ setAlertBox })
|
|
87
87
|
|
|
88
88
|
const [registerSalesStore, { loading: loadingRegisterSale }] = useMutation(
|
|
89
89
|
CREATE_SHOPPING_CARD_TO_USER_STORE,
|
|
90
90
|
{
|
|
91
91
|
onCompleted: (data) => {
|
|
92
92
|
const message = `${data?.registerSalesStore?.Response?.message}`;
|
|
93
|
-
const
|
|
94
|
-
const error = isSuccess
|
|
93
|
+
const error = data?.registerSalesStore?.Response.success
|
|
95
94
|
? "Éxito"
|
|
96
95
|
: "Error";
|
|
97
|
-
if (message === 'Token expired') {
|
|
98
|
-
setSalesOpen(false)
|
|
99
|
-
onClickLogout()
|
|
100
|
-
}
|
|
101
96
|
sendNotification({
|
|
102
|
-
backgroundColor:
|
|
97
|
+
backgroundColor: error ? 'success' : 'error',
|
|
103
98
|
title: error,
|
|
104
99
|
description: message
|
|
105
100
|
});
|
|
106
101
|
setAlertBox({ message: message, type: "success" });
|
|
107
|
-
|
|
108
|
-
if (isSuccess) {
|
|
109
|
-
setOpenCurrentSale(isSuccess);
|
|
110
|
-
}
|
|
102
|
+
setOpenCurrentSale(data?.registerSalesStore?.Response.success);
|
|
111
103
|
},
|
|
112
104
|
onError: (error) => {
|
|
113
105
|
console.log(error)
|
|
@@ -762,7 +754,6 @@ export const useSales = ({
|
|
|
762
754
|
}
|
|
763
755
|
const totalProductsPrice = totalProductPrice;
|
|
764
756
|
const client = useApolloClient()
|
|
765
|
-
const { getOnePedidoStore, error: saleError } = useGetSale()
|
|
766
757
|
|
|
767
758
|
const handleSubmit = () => {
|
|
768
759
|
if (!values?.cliId)
|
|
@@ -786,15 +777,14 @@ export const useSales = ({
|
|
|
786
777
|
discount: discount.discount || 0,
|
|
787
778
|
totalProductsPrice: totalProductsPrice || 0,
|
|
788
779
|
}
|
|
789
|
-
})
|
|
780
|
+
})
|
|
781
|
+
.then((responseRegisterR) => {
|
|
790
782
|
if (responseRegisterR) {
|
|
791
783
|
const { data } = responseRegisterR || {};
|
|
792
784
|
const { registerSalesStore } = data || {};
|
|
793
785
|
const { Response } = registerSalesStore || {};
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
console.log(responseRegisterR)
|
|
797
|
-
if (!process.env.NODE_ENV === 'development') dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
|
|
786
|
+
if (Response && Response.success === true) {
|
|
787
|
+
// dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
|
|
798
788
|
client.query({
|
|
799
789
|
query: GET_ALL_COUNT_SALES,
|
|
800
790
|
fetchPolicy: 'network-only',
|
|
@@ -802,28 +792,6 @@ export const useSales = ({
|
|
|
802
792
|
client.writeQuery({ query: GET_ALL_COUNT_SALES, data: { getTodaySales: data.countSales.todaySales } })
|
|
803
793
|
}
|
|
804
794
|
})
|
|
805
|
-
getOnePedidoStore({
|
|
806
|
-
variables: {
|
|
807
|
-
pCodeRef: code || ''
|
|
808
|
-
}
|
|
809
|
-
}).then((res) => {
|
|
810
|
-
console.log(res)
|
|
811
|
-
const currentSale = res?.data?.getOnePedidoStore
|
|
812
|
-
if (currentSale && !saleError) {
|
|
813
|
-
client.cache.modify({
|
|
814
|
-
fields: {
|
|
815
|
-
getAllOrdersFromStore(existingOrders = []) {
|
|
816
|
-
try {
|
|
817
|
-
const cache = updateExistingOrders(existingOrders, code, 4, currentSale)
|
|
818
|
-
return cache
|
|
819
|
-
} catch (e) {
|
|
820
|
-
return existingOrders
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
})
|
|
825
|
-
}
|
|
826
|
-
})
|
|
827
795
|
router.push(
|
|
828
796
|
{
|
|
829
797
|
query: {
|
|
@@ -834,7 +802,7 @@ export const useSales = ({
|
|
|
834
802
|
undefined,
|
|
835
803
|
{ shallow: true }
|
|
836
804
|
);
|
|
837
|
-
|
|
805
|
+
// setValues({})
|
|
838
806
|
}
|
|
839
807
|
}
|
|
840
808
|
setLoadingSale(false);
|
|
@@ -862,17 +830,18 @@ export const useSales = ({
|
|
|
862
830
|
const optionalAll = await ExtProductFoodsSubOptionalAll({
|
|
863
831
|
variables: { pId },
|
|
864
832
|
});
|
|
865
|
-
const optionalFetch = optionalAll
|
|
833
|
+
const optionalFetch = optionalAll.data.ExtProductFoodsOptionalAll;
|
|
866
834
|
setDataOptional(optionalFetch || []);
|
|
867
835
|
const existOptionalCookies = originalArray?.dataOptional;
|
|
868
836
|
const filteredDataOptional = existOptionalCookies?.length
|
|
869
837
|
? existOptionalCookies
|
|
870
838
|
?.map((obj) => {
|
|
871
|
-
const filteredSubOptions =
|
|
872
|
-
|
|
839
|
+
const filteredSubOptions =
|
|
840
|
+
obj.ExtProductFoodsSubOptionalAll.filter(
|
|
841
|
+
(subObj) => subObj.check === true
|
|
873
842
|
);
|
|
874
843
|
// Excluya todo el objeto padre si filteredSubOptions está vacío
|
|
875
|
-
if (filteredSubOptions
|
|
844
|
+
if (filteredSubOptions.length === 0) {
|
|
876
845
|
return null;
|
|
877
846
|
}
|
|
878
847
|
return {
|
|
@@ -94,60 +94,52 @@ export const GET_ALL_SALES_STATISTICS = gql`
|
|
|
94
94
|
`;
|
|
95
95
|
|
|
96
96
|
export const GET_ONE_SALES = gql`
|
|
97
|
-
query getOnePedidoStore($pCodeRef: String) {
|
|
98
|
-
|
|
99
|
-
pdpId
|
|
100
|
-
pCodeRef
|
|
101
|
-
idStore
|
|
102
|
-
pPDate
|
|
103
|
-
channel
|
|
104
|
-
change
|
|
105
|
-
pSState
|
|
106
|
-
pDatCre
|
|
107
|
-
id
|
|
108
|
-
pDatMod
|
|
109
|
-
pPRecoger
|
|
110
|
-
payMethodPState
|
|
111
|
-
pdpId
|
|
112
|
-
totalProductsPrice
|
|
113
|
-
locationUser
|
|
114
|
-
getUser {
|
|
115
|
-
id
|
|
116
|
-
email
|
|
117
|
-
uPhoNum
|
|
118
|
-
ULocation
|
|
119
|
-
}
|
|
120
|
-
getAllPedidoStore {
|
|
97
|
+
query getOnePedidoStore($pCodeRef: String) {
|
|
98
|
+
getOnePedidoStore(pCodeRef: $pCodeRef) {
|
|
121
99
|
pdpId
|
|
122
|
-
idStore
|
|
123
100
|
pCodeRef
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
126
116
|
ShoppingCard
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
getAllShoppingCard {
|
|
118
|
+
ShoppingCard
|
|
119
|
+
cantProducts
|
|
120
|
+
subProductsId
|
|
121
|
+
comments
|
|
132
122
|
pId
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
}
|
|
146
139
|
}
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
}
|
|
150
|
-
}
|
|
151
143
|
`;
|
|
152
144
|
|
|
153
145
|
export const CREATE_CLIENTS = gql`
|
|
@@ -266,9 +258,7 @@ export const GET_ONE_SALE = gql`
|
|
|
266
258
|
pCodeRef
|
|
267
259
|
idStore
|
|
268
260
|
pPDate
|
|
269
|
-
id
|
|
270
261
|
channel
|
|
271
|
-
change
|
|
272
262
|
pSState
|
|
273
263
|
pDatCre
|
|
274
264
|
pDatMod
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { useLazyQuery } from '@apollo/client'
|
|
2
2
|
import { GET_ONE_SALE } from './queries'
|
|
3
3
|
|
|
4
|
-
export const useGetSale = (
|
|
5
|
-
const [getOnePedidoStore, {
|
|
6
|
-
loading,
|
|
7
|
-
data,
|
|
8
|
-
called,
|
|
9
|
-
error
|
|
10
|
-
}] = useLazyQuery(GET_ONE_SALE, {
|
|
11
|
-
onCompleted: (res) => {
|
|
12
|
-
if (res?.getOnePedidoStore) {
|
|
13
|
-
return callback(res)
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
onError: () => {
|
|
17
|
-
return callback(null)
|
|
18
|
-
}
|
|
19
|
-
})
|
|
4
|
+
export const useGetSale = () => {
|
|
5
|
+
const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
|
|
20
6
|
return {
|
|
21
7
|
data: data?.getOnePedidoStore, // actualizado aquí
|
|
22
8
|
loading,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { GET_ONE_SCHEDULE_STORE, GET_SCHEDULE_STORE } from '../useProductsFood/queriesStore'
|
|
3
|
+
|
|
4
|
+
export const useSchedule = ({ day = null }) => {
|
|
5
|
+
const {
|
|
6
|
+
data,
|
|
7
|
+
loading,
|
|
8
|
+
error
|
|
9
|
+
} = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day } })
|
|
10
|
+
|
|
11
|
+
return [data?.getOneStoreSchedules, { loading, error }]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useSchedules = ({ schDay = 1 }) => {
|
|
15
|
+
const {
|
|
16
|
+
data,
|
|
17
|
+
loading,
|
|
18
|
+
error
|
|
19
|
+
} = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay } })
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
return [data?.getStoreSchedules, { loading, error }]
|
|
23
|
+
}
|
|
@@ -36,11 +36,7 @@ export const useGetOneUseStoreContacts = ({ sendNotification = () => { return }
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export const useEditOneUseStoreContacts = ({ sendNotification = () => { return } } = {}) => {
|
|
39
|
-
const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT
|
|
40
|
-
onError: e => {
|
|
41
|
-
console.error(e)
|
|
42
|
-
}
|
|
43
|
-
})
|
|
39
|
+
const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT)
|
|
44
40
|
return [editOneContacts, { data: data?.editOneContacts, loading, error }]
|
|
45
41
|
}
|
|
46
42
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const isValidCodeRef = (codeRef) => {
|
|
2
|
-
return typeof codeRef ===
|
|
2
|
+
return typeof codeRef === "string" && codeRef.trim() !== "";
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
export const isValidState = (state) => {
|
|
@@ -13,11 +13,11 @@ export const updateExistingOrders = (
|
|
|
13
13
|
pSState,
|
|
14
14
|
objectToAdd
|
|
15
15
|
) => {
|
|
16
|
-
if (typeof existingOrders !==
|
|
16
|
+
if (typeof existingOrders !== "object" || existingOrders === null) {
|
|
17
17
|
// existingOrders no es un objeto válido
|
|
18
18
|
return existingOrders;
|
|
19
19
|
}
|
|
20
|
-
if (typeof pCodeRef !==
|
|
20
|
+
if (typeof pCodeRef !== "string" || typeof pSState !== "number") {
|
|
21
21
|
// Los tipos de datos de pCodeRef y pSState no son los esperados
|
|
22
22
|
return existingOrders;
|
|
23
23
|
}
|
|
@@ -29,11 +29,11 @@ export const updateExistingOrders = (
|
|
|
29
29
|
const updatedExistingOrders = { ...existingOrders }; // Copiar el objeto existente
|
|
30
30
|
|
|
31
31
|
const statusKeys = {
|
|
32
|
-
1:
|
|
33
|
-
2:
|
|
34
|
-
3:
|
|
35
|
-
4:
|
|
36
|
-
5:
|
|
32
|
+
1: "ACEPTA",
|
|
33
|
+
2: "PROCESSING",
|
|
34
|
+
3: "READY",
|
|
35
|
+
4: "CONCLUDES",
|
|
36
|
+
5: "RECHAZADOS",
|
|
37
37
|
};
|
|
38
38
|
const targetArray = statusKeys[pSState];
|
|
39
39
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMutation, useQuery } from '@apollo/client'
|
|
2
2
|
import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
|
|
3
3
|
|
|
4
4
|
export const useUser = () => {
|
|
@@ -8,7 +8,7 @@ export const useUser = () => {
|
|
|
8
8
|
|
|
9
9
|
export const useUserProfile = () => {
|
|
10
10
|
const { data, loading, error } = useQuery(GET_USER_PROFILE)
|
|
11
|
-
return [data
|
|
11
|
+
return [data, { loading, error }]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const useSetUserProfile = () => {
|