npm-pkg-hook 1.1.5 → 1.1.9
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 +19 -113
- package/.eslintrc.json +127 -108
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/next.config.js +2 -5
- package/package.json +27 -24
- package/script.txt +6 -6
- package/src/config/client/errors.js +14 -14
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
- package/src/hooks/getCategoriesWithProduct/index.js +62 -0
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/index.js +13 -9
- package/src/hooks/useAcumulateDate/index.js +1 -1
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/helpers/index.js +22 -0
- package/src/hooks/useAsideCart/index.js +156 -0
- package/src/hooks/useAsideCart/queries.js +10 -0
- package/src/hooks/useBanner/index.js +11 -11
- package/src/hooks/useCart/index.js +2 -0
- package/src/hooks/useCart/queries.js +164 -0
- package/src/hooks/useCart/useCart/helpers/index.js +75 -0
- package/src/hooks/useCart/useCart/index.js +411 -0
- package/src/hooks/useCart/useGetCart/index.js +31 -0
- package/src/hooks/useCatWithProduct/index.js +15 -15
- package/src/hooks/useCatWithProduct/queries.js +1 -1
- package/src/hooks/useCatWithProductClient/index.js +48 -0
- package/src/hooks/useCatWithProductClient/queries.js +55 -0
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/index.js +39 -36
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useCategoryStore/index.js +2 -2
- package/src/hooks/useChartData/index.js +159 -156
- package/src/hooks/useChartData/useChartData/index.js +199 -197
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useClients/index.js +12 -14
- package/src/hooks/useClients/queries.js +1 -1
- package/src/hooks/useConnection/index.js +20 -21
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
- package/src/hooks/useCreateProduct/index.js +22 -19
- package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDessert/index.js +56 -65
- package/src/hooks/useDevices/index.js +35 -36
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -79
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEmployee/queries.js +1 -1
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -0
- package/src/hooks/useFavoriteStores/queries.js +47 -0
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -176
- package/src/hooks/useFormTools/index.js +12 -11
- package/src/hooks/useFormatDate/index.js +20 -21
- package/src/hooks/useFormatNumberPhone/index.js +9 -9
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
- package/src/hooks/useGetFoodRecomended/index.js +33 -0
- package/src/hooks/useGetFoodRecomended/queries.js +47 -0
- package/src/hooks/useGetMinPrice/index.js +8 -0
- package/src/hooks/useGetMinPrice/queries.js +7 -0
- package/src/hooks/useGetOneStoreRating/index.js +40 -0
- package/src/hooks/useGetOneStoreRating/queries.js +18 -0
- package/src/hooks/useGoogleLogin/index.js +160 -161
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImageOptimization/index.js +15 -15
- package/src/hooks/useImageWeight/index.js +18 -19
- package/src/hooks/useImagesStore/index.js +139 -140
- package/src/hooks/useImagesStore/queries.js +19 -18
- package/src/hooks/useInnerHtml/index.js +39 -38
- package/src/hooks/useIntersection/index.js +4 -4
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLazyScript/index.js +35 -36
- package/src/hooks/useLocalSorage/index.js +2 -2
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useLogout/index.js +24 -24
- package/src/hooks/useManageQueryParams/index.js +36 -37
- package/src/hooks/useMobile/index.js +39 -38
- package/src/hooks/useMutateHeight/index.js +15 -16
- package/src/hooks/useOrderClient/index.js +5 -0
- package/src/hooks/useOrders/index.js +10 -16
- package/src/hooks/useOrders/queries.js +1 -1
- package/src/hooks/useProductsFood/index.js +32 -32
- package/src/hooks/useProductsFood/queriesStore.js +49 -48
- package/src/hooks/useProductsFood/useEditProduct.js +2 -4
- package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
- package/src/hooks/useProvidersStore/index.js +24 -24
- package/src/hooks/useProvidersStore/queries.js +31 -31
- package/src/hooks/useRatingArrayData/index.js +54 -0
- package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
- package/src/hooks/useReactToPrint/index.js +1120 -1098
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useReport/index.js +9 -9
- package/src/hooks/useReport/queries.js +1 -1
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/index.js +476 -451
- package/src/hooks/useSales/queries.js +14 -15
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSales/useTotalSales.js +18 -18
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
- package/src/hooks/useSaveAvailableProduct/index.js +16 -16
- package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
- package/src/hooks/useSchedule/index.js +33 -36
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +34 -35
- package/src/hooks/useScheduleData/index.js +123 -171
- package/src/hooks/useScroll/index.js +56 -57
- package/src/hooks/useScrollRotate/index.js +16 -14
- package/src/hooks/useSetSession/index.js +16 -16
- package/src/hooks/useSetState/index.js +3 -3
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
- package/src/hooks/useStatusOpenStore/index.js +172 -173
- package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
- package/src/hooks/useStatusOrdersClient/index.js +17 -0
- package/src/hooks/useStatusOrdersClient/queries.js +80 -0
- package/src/hooks/useStore/index.js +40 -25
- package/src/hooks/useStore/queries.js +162 -136
- package/src/hooks/useStoreCalendar/index.js +5 -7
- package/src/hooks/useStoreContacts/index.js +16 -16
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateCart/index.js +34 -28
- package/src/hooks/useUpdateExistingOrders/index.js +35 -35
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
- package/src/hooks/useUser/index.js +1 -1
- package/src/hooks/useUser/queries.js +1 -1
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -2
- package/src/utils/index.js +42 -45
- package/src/hooks/useRatingData/index.js +0 -53
- package/src/hooks/useSalesClient/index.js +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_PEDIDOS_STATUS = gql`
|
|
4
|
+
query getAllPedidoUserFinal($id: ID) {
|
|
5
|
+
getAllPedidoUserFinal(id: $id) {
|
|
6
|
+
pdpId
|
|
7
|
+
idStore
|
|
8
|
+
pCodeRef
|
|
9
|
+
payMethodPState
|
|
10
|
+
pPRecoger
|
|
11
|
+
totalProductsPrice
|
|
12
|
+
pSState
|
|
13
|
+
getOneStore {
|
|
14
|
+
idStore
|
|
15
|
+
cId
|
|
16
|
+
id
|
|
17
|
+
dId
|
|
18
|
+
ctId
|
|
19
|
+
neighborhoodStore
|
|
20
|
+
Viaprincipal
|
|
21
|
+
storeOwner
|
|
22
|
+
storeName
|
|
23
|
+
emailStore
|
|
24
|
+
storePhone
|
|
25
|
+
Image
|
|
26
|
+
pais {
|
|
27
|
+
cId
|
|
28
|
+
cName
|
|
29
|
+
}
|
|
30
|
+
city {
|
|
31
|
+
ctId
|
|
32
|
+
cName
|
|
33
|
+
dId
|
|
34
|
+
}
|
|
35
|
+
department {
|
|
36
|
+
dId
|
|
37
|
+
cId
|
|
38
|
+
dName
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
pDatCre
|
|
42
|
+
locationUser
|
|
43
|
+
pDatMod
|
|
44
|
+
getAllPedidoStore {
|
|
45
|
+
pdpId
|
|
46
|
+
pId
|
|
47
|
+
idStore
|
|
48
|
+
ShoppingCard
|
|
49
|
+
pCodeRef
|
|
50
|
+
pPStateP
|
|
51
|
+
payMethodPState
|
|
52
|
+
pPRecoger
|
|
53
|
+
pDatCre
|
|
54
|
+
pDatMod
|
|
55
|
+
getAllShoppingCard {
|
|
56
|
+
ShoppingCard
|
|
57
|
+
comments
|
|
58
|
+
cantProducts
|
|
59
|
+
pId
|
|
60
|
+
productFood {
|
|
61
|
+
pId
|
|
62
|
+
carProId
|
|
63
|
+
colorId
|
|
64
|
+
idStore
|
|
65
|
+
pName
|
|
66
|
+
ProPrice
|
|
67
|
+
ProDescuento
|
|
68
|
+
ProDescription
|
|
69
|
+
ValueDelivery
|
|
70
|
+
ProImage
|
|
71
|
+
ProStar
|
|
72
|
+
pState
|
|
73
|
+
pDatCre
|
|
74
|
+
pDatMod
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`
|
|
@@ -1,61 +1,76 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import { useApolloClient, useQuery } from '@apollo/client'
|
|
3
|
-
import { GET_ONE_STORE } from './queries'
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
import { useApolloClient, useQuery } from '@apollo/client'
|
|
3
|
+
import { GET_ONE_STORE, GET_ONE_STORE_BY_ID } from './queries' // Reemplaza con la importación correcta de tu consulta
|
|
4
4
|
import { errorHandler } from '../../config/client'
|
|
5
5
|
import { useLogout } from '../useLogout'
|
|
6
6
|
|
|
7
|
-
export const useStore = () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export const useStore = ({ isClient = false, idStore = '' } = {}) => {
|
|
8
|
+
const { data, refetch, loading: loadingClient, error: errorStoreClient } = useQuery(GET_ONE_STORE_BY_ID, {
|
|
9
|
+
skip: !isClient,
|
|
10
|
+
variables: {
|
|
11
|
+
idStore
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const [store, setStore] = useState({})
|
|
16
|
+
const client = useApolloClient()
|
|
17
|
+
const [onClickLogout, { loading: load }] = useLogout()
|
|
11
18
|
|
|
12
19
|
// Intentar leer los datos de la caché
|
|
13
|
-
const cachedData = client.readQuery({ query: GET_ONE_STORE })
|
|
20
|
+
const cachedData = client.readQuery({ query: GET_ONE_STORE })
|
|
14
21
|
|
|
15
22
|
useEffect(() => {
|
|
16
23
|
if (cachedData) {
|
|
17
24
|
// Comprobar si los datos de la caché ya están establecidos en el estado
|
|
18
25
|
if (!store || Object.keys(store).length === 0) {
|
|
19
|
-
setStore(cachedData.getStore)
|
|
26
|
+
setStore(cachedData.getStore)
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
|
-
}, [cachedData, store])
|
|
29
|
+
}, [cachedData, store])
|
|
23
30
|
|
|
24
31
|
const { loading, error } = useQuery(GET_ONE_STORE, {
|
|
32
|
+
skip: isClient,
|
|
25
33
|
fetchPolicy: 'cache-first',
|
|
26
34
|
onCompleted: (data) => {
|
|
27
|
-
const { getStore } = data || {}
|
|
28
|
-
setStore(getStore)
|
|
35
|
+
const { getStore } = data || {}
|
|
36
|
+
setStore(getStore)
|
|
29
37
|
},
|
|
30
38
|
onError: (err) => {
|
|
31
39
|
if (err.networkError && err.networkError.result) {
|
|
32
|
-
const response = errorHandler(err.networkError.result)
|
|
40
|
+
const response = errorHandler(err.networkError.result)
|
|
33
41
|
if (response) {
|
|
34
|
-
onClickLogout()
|
|
42
|
+
onClickLogout()
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
|
-
}
|
|
38
|
-
})
|
|
45
|
+
}
|
|
46
|
+
})
|
|
39
47
|
|
|
40
48
|
// Ejecutar la consulta y almacenarla en la caché
|
|
41
49
|
useEffect(() => {
|
|
42
50
|
client.query({ query: GET_ONE_STORE }).then(() => {
|
|
43
51
|
// Leer la consulta desde la caché
|
|
44
|
-
const cacheData = client.readQuery({ query: GET_ONE_STORE })
|
|
52
|
+
const cacheData = client.readQuery({ query: GET_ONE_STORE })
|
|
45
53
|
setStore(cacheData?.getStore)
|
|
46
|
-
})
|
|
47
|
-
}, [client])
|
|
54
|
+
})
|
|
55
|
+
}, [client])
|
|
48
56
|
|
|
49
57
|
// Actualizar manualmente la caché después de cada petición exitosa
|
|
50
58
|
useEffect(() => {
|
|
51
59
|
if (!loading && !error && !cachedData) {
|
|
52
60
|
client.writeQuery({
|
|
53
61
|
query: GET_ONE_STORE,
|
|
54
|
-
data: { getStore: store }
|
|
55
|
-
})
|
|
62
|
+
data: { getStore: store }
|
|
63
|
+
})
|
|
56
64
|
}
|
|
57
|
-
}, [loading, error, cachedData, client, store])
|
|
58
|
-
|
|
59
|
-
return [store, { loading: load || loading, error }];
|
|
60
|
-
};
|
|
65
|
+
}, [loading, error, cachedData, client, store])
|
|
61
66
|
|
|
67
|
+
if (isClient) {
|
|
68
|
+
const dataOneStoreClient = !loadingClient ? data?.getOneStore : {}
|
|
69
|
+
return [dataOneStoreClient, {
|
|
70
|
+
refetch,
|
|
71
|
+
loading: loadingClient,
|
|
72
|
+
error: errorStoreClient
|
|
73
|
+
}]
|
|
74
|
+
}
|
|
75
|
+
return [store, { loading: load || loading, error }]
|
|
76
|
+
}
|
|
@@ -1,136 +1,162 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CREATE_ONE_STORE = gql`
|
|
4
|
-
mutation newRegisterStore($input: IStore){
|
|
5
|
-
newRegisterStore(input: $input){
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
idStore
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getStore(id: $
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
getOneStore(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
NitStore
|
|
121
|
-
typeRegiments
|
|
122
|
-
typeContribute
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const CREATE_ONE_STORE = gql`
|
|
4
|
+
mutation newRegisterStore($input: IStore){
|
|
5
|
+
newRegisterStore(input: $input){
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
idStore
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const GET_ONE_STORE = gql`
|
|
14
|
+
query getStore($id: ID, $idStore: ID){
|
|
15
|
+
getStore(id: $id, idStore: $idStore){
|
|
16
|
+
cId
|
|
17
|
+
id
|
|
18
|
+
dId
|
|
19
|
+
idStore
|
|
20
|
+
ctId
|
|
21
|
+
neighborhoodStore
|
|
22
|
+
Viaprincipal
|
|
23
|
+
catStore
|
|
24
|
+
storeOwner
|
|
25
|
+
storeName
|
|
26
|
+
ImageName
|
|
27
|
+
emailStore
|
|
28
|
+
storePhone
|
|
29
|
+
socialRaz
|
|
30
|
+
Image
|
|
31
|
+
banner
|
|
32
|
+
|
|
33
|
+
documentIdentifier
|
|
34
|
+
uPhoNum
|
|
35
|
+
storeName
|
|
36
|
+
ULocation
|
|
37
|
+
upLat
|
|
38
|
+
upLon
|
|
39
|
+
uState
|
|
40
|
+
siteWeb
|
|
41
|
+
|
|
42
|
+
description
|
|
43
|
+
createdAt
|
|
44
|
+
secVia
|
|
45
|
+
NitStore
|
|
46
|
+
typeRegiments
|
|
47
|
+
typeContribute
|
|
48
|
+
addressStore
|
|
49
|
+
pais {
|
|
50
|
+
cId
|
|
51
|
+
cName
|
|
52
|
+
cCalCod
|
|
53
|
+
cState
|
|
54
|
+
cDatCre
|
|
55
|
+
cDatMod
|
|
56
|
+
}
|
|
57
|
+
city {
|
|
58
|
+
ctId
|
|
59
|
+
dId
|
|
60
|
+
cName
|
|
61
|
+
cState
|
|
62
|
+
cDatCre
|
|
63
|
+
cDatMod
|
|
64
|
+
}
|
|
65
|
+
department {
|
|
66
|
+
dId
|
|
67
|
+
cId
|
|
68
|
+
dName
|
|
69
|
+
dState
|
|
70
|
+
dDatCre
|
|
71
|
+
dDatMod
|
|
72
|
+
}
|
|
73
|
+
getStoreSchedules {
|
|
74
|
+
idStore
|
|
75
|
+
schId
|
|
76
|
+
id
|
|
77
|
+
schDay
|
|
78
|
+
schHoSta
|
|
79
|
+
schHoEnd
|
|
80
|
+
schState
|
|
81
|
+
}
|
|
82
|
+
cateStore {
|
|
83
|
+
catStore
|
|
84
|
+
cName
|
|
85
|
+
cState
|
|
86
|
+
cDatCre
|
|
87
|
+
cDatMod
|
|
88
|
+
csDescription
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`
|
|
94
|
+
export const GET_ONE_STORE_BY_ID = gql`
|
|
95
|
+
query getOneStore($StoreName: String, $idStore: ID){
|
|
96
|
+
getOneStore(idStore: $idStore, StoreName: $StoreName) {
|
|
97
|
+
idStore
|
|
98
|
+
cId
|
|
99
|
+
id
|
|
100
|
+
dId
|
|
101
|
+
ctId
|
|
102
|
+
catStore
|
|
103
|
+
neighborhoodStore
|
|
104
|
+
Viaprincipal
|
|
105
|
+
storeOwner
|
|
106
|
+
storeName
|
|
107
|
+
emailStore
|
|
108
|
+
storePhone
|
|
109
|
+
socialRaz
|
|
110
|
+
Image
|
|
111
|
+
banner
|
|
112
|
+
documentIdentifier
|
|
113
|
+
uPhoNum
|
|
114
|
+
ULocation
|
|
115
|
+
upLat
|
|
116
|
+
upLon
|
|
117
|
+
uState
|
|
118
|
+
siteWeb
|
|
119
|
+
description
|
|
120
|
+
NitStore
|
|
121
|
+
typeRegiments
|
|
122
|
+
typeContribute
|
|
123
|
+
secVia
|
|
124
|
+
addressStore
|
|
125
|
+
createdAt
|
|
126
|
+
pais{
|
|
127
|
+
cId
|
|
128
|
+
cName
|
|
129
|
+
cCalCod
|
|
130
|
+
cState
|
|
131
|
+
cDatCre
|
|
132
|
+
cDatMod
|
|
133
|
+
}
|
|
134
|
+
city {
|
|
135
|
+
ctId
|
|
136
|
+
dId
|
|
137
|
+
cName
|
|
138
|
+
cState
|
|
139
|
+
cDatCre
|
|
140
|
+
cDatMod
|
|
141
|
+
}
|
|
142
|
+
department {
|
|
143
|
+
dId
|
|
144
|
+
cId
|
|
145
|
+
dName
|
|
146
|
+
dState
|
|
147
|
+
dDatCre
|
|
148
|
+
dDatMod
|
|
149
|
+
}
|
|
150
|
+
cateStore {
|
|
151
|
+
catStore
|
|
152
|
+
idUser
|
|
153
|
+
cName
|
|
154
|
+
cState
|
|
155
|
+
cDatCre
|
|
156
|
+
cDatMod
|
|
157
|
+
csDescription
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
`
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { useQuery, useMutation, useLazyQuery } from '@apollo/client'
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
GET_ALL_CONTACTS,
|
|
5
|
-
EDIT_ONE_CONTACT,
|
|
6
|
-
CREATE_CONTACTS,
|
|
3
|
+
import {
|
|
4
|
+
GET_ALL_CONTACTS,
|
|
5
|
+
EDIT_ONE_CONTACT,
|
|
6
|
+
CREATE_CONTACTS,
|
|
7
7
|
GET_ONE_CONTACT
|
|
8
8
|
} from './queries'
|
|
9
9
|
|
|
10
10
|
export const useGetStoreContacts = ({
|
|
11
|
-
sendNotification = () => {
|
|
11
|
+
sendNotification = () => { },
|
|
12
12
|
max,
|
|
13
13
|
search = ''
|
|
14
14
|
} = {}) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const [clientes, setUseStoreContacts] = useState([])
|
|
16
|
+
const { loading, error, fetchMore, called } = useQuery(GET_ALL_CONTACTS, {
|
|
17
|
+
variables: {
|
|
18
|
+
max,
|
|
19
|
+
search
|
|
20
|
+
},
|
|
21
21
|
onCompleted: (data) => {
|
|
22
|
-
|
|
22
|
+
setUseStoreContacts(data)
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
25
|
return [clientes?.getAllContacts || [], { loading: called ? false : loading, error, fetchMore }]
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const useDeleteUseStoreContacts = ({ sendNotification = () => {
|
|
28
|
+
export const useDeleteUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
29
29
|
const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
|
|
30
30
|
return [getOneContacts, data?.getOneContacts ?? {}, { loading, error }]
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const useGetOneUseStoreContacts = ({ sendNotification = () => {
|
|
33
|
+
export const useGetOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
34
34
|
const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
|
|
35
35
|
return [getOneContacts, { data: data?.getOneContacts, loading, error }]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export const useEditOneUseStoreContacts = ({ sendNotification = () => {
|
|
38
|
+
export const useEditOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
39
39
|
const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT)
|
|
40
40
|
return [editOneContacts, { data: data?.editOneContacts, loading, error }]
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export const useCreateContacts = ({ sendNotification = () => {
|
|
43
|
+
export const useCreateContacts = ({ sendNotification = () => { } } = {}) => {
|
|
44
44
|
const [createUseStoreContacts, { loading, error }] = useMutation(CREATE_CONTACTS)
|
|
45
45
|
|
|
46
46
|
return [createUseStoreContacts, { loading, error }]
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const DATE_UNITS = [
|
|
4
|
-
['day', 86400],
|
|
5
|
-
['hour', 3600],
|
|
6
|
-
['minute', 60],
|
|
7
|
-
['second', 1]
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
const getDateDiffs = (timestamp) => {
|
|
11
|
-
const now = Date.now()
|
|
12
|
-
const elapsed = (timestamp - now) / 1000
|
|
13
|
-
|
|
14
|
-
for (const [unit, secondsInUnit] of DATE_UNITS) {
|
|
15
|
-
if (Math.abs(elapsed) > secondsInUnit || unit === 'second') {
|
|
16
|
-
const value = Math.round(elapsed / secondsInUnit)
|
|
17
|
-
return { value, unit }
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const useTimeAgo = (timestamp) =>
|
|
23
|
-
const [timeAgo, setTimeAgo] = useState(() => { return getDateDiffs(timestamp) })
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const interval = setInterval(() => {
|
|
27
|
-
const newTimeAgo = getDateDiffs(timestamp)
|
|
28
|
-
setTimeAgo(newTimeAgo)
|
|
29
|
-
}, 5000)
|
|
30
|
-
|
|
31
|
-
return () => { return clearInterval(interval) }
|
|
32
|
-
}, [timestamp])
|
|
33
|
-
|
|
34
|
-
const rtf = new Intl.RelativeTimeFormat('es', { style: 'short' })
|
|
35
|
-
|
|
36
|
-
const { value, unit } = timeAgo
|
|
37
|
-
|
|
38
|
-
return rtf && rtf?.format(value, unit)
|
|
39
|
-
}
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const DATE_UNITS = [
|
|
4
|
+
['day', 86400],
|
|
5
|
+
['hour', 3600],
|
|
6
|
+
['minute', 60],
|
|
7
|
+
['second', 1]
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
const getDateDiffs = (timestamp) => {
|
|
11
|
+
const now = Date.now()
|
|
12
|
+
const elapsed = (timestamp - now) / 1000
|
|
13
|
+
|
|
14
|
+
for (const [unit, secondsInUnit] of DATE_UNITS) {
|
|
15
|
+
if (Math.abs(elapsed) > secondsInUnit || unit === 'second') {
|
|
16
|
+
const value = Math.round(elapsed / secondsInUnit)
|
|
17
|
+
return { value, unit }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const useTimeAgo = (timestamp) => {
|
|
23
|
+
const [timeAgo, setTimeAgo] = useState(() => { return getDateDiffs(timestamp) })
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const interval = setInterval(() => {
|
|
27
|
+
const newTimeAgo = getDateDiffs(timestamp)
|
|
28
|
+
setTimeAgo(newTimeAgo)
|
|
29
|
+
}, 5000)
|
|
30
|
+
|
|
31
|
+
return () => { return clearInterval(interval) }
|
|
32
|
+
}, [timestamp])
|
|
33
|
+
|
|
34
|
+
const rtf = new Intl.RelativeTimeFormat('es', { style: 'short' })
|
|
35
|
+
|
|
36
|
+
const { value, unit } = timeAgo
|
|
37
|
+
|
|
38
|
+
return rtf && rtf?.format(value, unit)
|
|
39
|
+
}
|