npm-pkg-hook 1.0.7 → 1.0.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/package.json +1 -1
- package/src/config/client/errors.js +24 -0
- package/src/config/client/index.js +1 -0
- package/src/hooks/index.js +5 -0
- package/src/hooks/useCatWithProduct/queries.js +5 -5
- package/src/hooks/useCategoryInStore/index.js +1 -0
- package/src/hooks/useClients/index.js +63 -13
- package/src/hooks/useClients/queries.js +10 -1
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +9 -2
- package/src/hooks/useCreateProduct/index.js +28 -13
- package/src/hooks/useEmployee/index.js +13 -0
- package/src/hooks/useEmployee/queries.js +17 -0
- package/src/hooks/useFetchMoreInteractions/index.jsx +2 -1
- package/src/hooks/useFormTools/index.js +22 -8
- package/src/hooks/useImagesStore/index.js +16 -5
- package/src/hooks/useImagesStore/queries.js +213 -173
- package/src/hooks/useLazyScript/index.js +3 -3
- package/src/hooks/useLogout/index.js +41 -0
- package/src/hooks/useOrders/index.js +81 -0
- package/src/hooks/useOrders/queries.js +328 -0
- package/src/hooks/useProductsFood/index.js +3 -3
- package/src/hooks/useProductsFood/queriesStore.js +632 -526
- package/src/hooks/useProductsFood/usetagsProducts.js +22 -10
- package/src/hooks/useReport/queries.js +2 -1
- package/src/hooks/useSales/index.js +101 -52
- package/src/hooks/useSetSession/index.js +21 -0
- package/src/hooks/useStore/index.js +42 -13
- package/src/hooks/useStoreContacts/index.js +47 -0
- package/src/hooks/useStoreContacts/queries.js +48 -0
- package/src/hooks/useUser/index.js +6 -1
- package/src/hooks/useUser/queries.js +18 -0
- package/src/utils/index.js +46 -9
|
@@ -1,101 +1,120 @@
|
|
|
1
|
-
import { gql } from
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
export const CREATE_SCHEDULE_STORE = gql`
|
|
4
|
-
mutation setStoreSchedule($input: IsStoreSchedule!){
|
|
5
|
-
setStoreSchedule(input: $input){
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
4
|
+
mutation setStoreSchedule($input: IsStoreSchedule!) {
|
|
5
|
+
setStoreSchedule(input: $input) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
11
|
export const GET_SCHEDULE_STORE = gql`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
query getStoreSchedules($schDay: Int, $idStore: ID) {
|
|
13
|
+
getStoreSchedules(schDay: $schDay, idStore: $idStore) {
|
|
14
|
+
schId
|
|
15
|
+
idStore
|
|
16
|
+
schDay
|
|
17
|
+
schHoSta
|
|
18
|
+
schHoEnd
|
|
19
|
+
schState
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
23
|
export const GET_ONE_SCHEDULE_STORE = gql`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
query getOneStoreSchedules($schDay: Int, $idStore: ID) {
|
|
25
|
+
getOneStoreSchedules(schDay: $schDay, idStore: $idStore) {
|
|
26
|
+
schId
|
|
27
|
+
schDay
|
|
28
|
+
schHoSta
|
|
29
|
+
schHoEnd
|
|
30
|
+
schState
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
34
|
export const GET_CAT_OF_PRODUCTS = gql`
|
|
35
|
-
query getAllCatOfProducts($idStore: ID) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
`
|
|
35
|
+
query getAllCatOfProducts($idStore: ID) {
|
|
36
|
+
getAllCatOfProducts(idStore: $idStore) {
|
|
37
|
+
id
|
|
38
|
+
cpId
|
|
39
|
+
catName
|
|
40
|
+
catDescription
|
|
41
|
+
schState
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
46
45
|
export const REGISTER_CAT_OF_PRODUCTS = gql`
|
|
47
|
-
mutation
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
mutation updatedProducts($input: InputCatProducts) {
|
|
47
|
+
updatedProducts(input: $input) {
|
|
48
|
+
success
|
|
49
|
+
message
|
|
50
|
+
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
`
|
|
52
|
+
`;
|
|
54
53
|
export const REGISTER_CONTRACT_STORE = gql`
|
|
55
|
-
mutation createOneContract($input: InputContractType) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
mutation createOneContract($input: InputContractType) {
|
|
55
|
+
createOneContract(input: $input) {
|
|
56
|
+
success
|
|
57
|
+
message
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
`
|
|
60
|
+
`;
|
|
62
61
|
export const GET_ALL_EMPLOYEE_STORE = gql`
|
|
63
|
-
query employees
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
62
|
+
query employees($umId: ID, $cId: ID, $aId: ID) {
|
|
63
|
+
employees(umId: $umId, cId: $cId, aId: $aId) {
|
|
64
|
+
eId
|
|
65
|
+
idStore
|
|
66
|
+
id
|
|
67
|
+
idEmployee
|
|
68
|
+
eSalary
|
|
69
|
+
typeContract
|
|
70
|
+
uEmail
|
|
71
|
+
termContract
|
|
72
|
+
eDatAdm
|
|
73
|
+
eState
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
78
77
|
export const GET_ALL_PRODUCT_STORE = gql`
|
|
79
|
-
query productFoodsAll(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
query productFoodsAll(
|
|
79
|
+
$search: String
|
|
80
|
+
$min: Int
|
|
81
|
+
$max: Int
|
|
82
|
+
$gender: [String]
|
|
83
|
+
$pState: Int
|
|
84
|
+
$desc: [String]
|
|
85
|
+
$categories: [ID]
|
|
86
|
+
$fromDate: DateTime
|
|
87
|
+
$toDate: DateTime
|
|
88
|
+
) {
|
|
89
|
+
productFoodsAll(
|
|
90
|
+
search: $search
|
|
91
|
+
min: $min
|
|
92
|
+
max: $max
|
|
93
|
+
gender: $gender
|
|
94
|
+
desc: $desc
|
|
95
|
+
pState: $pState
|
|
96
|
+
categories: $categories
|
|
97
|
+
toDate: $toDate
|
|
98
|
+
fromDate: $fromDate
|
|
99
|
+
) {
|
|
100
|
+
pId
|
|
101
|
+
sizeId #Talla
|
|
102
|
+
colorId #Color
|
|
103
|
+
cId #Country
|
|
104
|
+
dId #Department
|
|
105
|
+
ctId #Cuidad
|
|
106
|
+
fId #Características
|
|
107
|
+
pName
|
|
108
|
+
ProPrice
|
|
109
|
+
ProDescuento
|
|
110
|
+
free
|
|
92
111
|
ProUniDisponibles
|
|
93
112
|
ProDescription
|
|
94
113
|
ProProtegido
|
|
95
114
|
ProAssurance
|
|
96
115
|
ValueDelivery
|
|
97
116
|
ProStar
|
|
98
|
-
|
|
117
|
+
sTateLogistic
|
|
99
118
|
ProImage
|
|
100
119
|
ProWidth
|
|
101
120
|
ProHeight
|
|
@@ -103,114 +122,135 @@ query productFoodsAll($search: String, $min: Int, $max: Int, $gender: [String],
|
|
|
103
122
|
ProWeight
|
|
104
123
|
ProQuantity
|
|
105
124
|
ProOutstanding
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
pDatCre
|
|
126
|
+
pDatMod
|
|
108
127
|
ProDelivery
|
|
109
128
|
ProVoltaje
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
pState
|
|
130
|
+
feat {
|
|
131
|
+
fId
|
|
132
|
+
thpId
|
|
133
|
+
hpqrQuestion
|
|
134
|
+
}
|
|
135
|
+
area {
|
|
136
|
+
aId
|
|
137
|
+
aName
|
|
138
|
+
}
|
|
119
139
|
}
|
|
120
|
-
|
|
121
140
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
`
|
|
141
|
+
`;
|
|
125
142
|
export const GET_ALL_RATING_START_STORE = gql`
|
|
126
|
-
query getAllRatingStar($idStore: ID){
|
|
127
|
-
getAllRatingStar(idStore: $idStore){
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
143
|
+
query getAllRatingStar($idStore: ID) {
|
|
144
|
+
getAllRatingStar(idStore: $idStore) {
|
|
145
|
+
rSId
|
|
146
|
+
rScore
|
|
147
|
+
idStore
|
|
148
|
+
createAt
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
135
152
|
export const GET_ALL_VISITOR_STORE = gql`
|
|
136
|
-
query getAllVisitorStore(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
query getAllVisitorStore(
|
|
154
|
+
$idStore: ID
|
|
155
|
+
$search: String
|
|
156
|
+
$min: Int
|
|
157
|
+
$max: Int
|
|
158
|
+
$fromDate: DateTime
|
|
159
|
+
$toDate: DateTime
|
|
160
|
+
) {
|
|
161
|
+
getAllVisitorStore(
|
|
162
|
+
idStore: $idStore
|
|
163
|
+
search: $search
|
|
164
|
+
min: $min
|
|
165
|
+
max: $max
|
|
166
|
+
fromDate: $fromDate
|
|
167
|
+
toDate: $toDate
|
|
168
|
+
) {
|
|
169
|
+
visitStoreId
|
|
170
|
+
id
|
|
171
|
+
idStore
|
|
172
|
+
createAt
|
|
173
|
+
updateAt
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
146
177
|
export const GET_MIN_PEDIDO = gql`
|
|
147
|
-
query getMinPrice($idStore: ID){
|
|
148
|
-
getMinPrice(idStore: $idStore)
|
|
149
|
-
}
|
|
150
|
-
|
|
178
|
+
query getMinPrice($idStore: ID) {
|
|
179
|
+
getMinPrice(idStore: $idStore)
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
151
182
|
|
|
152
183
|
export const GET_All_RATING_STORE = gql`
|
|
153
|
-
query getAllRating($idStore: ID){
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
184
|
+
query getAllRating($idStore: ID) {
|
|
185
|
+
getAllRating(idStore: $idStore) {
|
|
186
|
+
idStore
|
|
187
|
+
rId
|
|
188
|
+
id
|
|
189
|
+
rAppearance
|
|
190
|
+
rTasty
|
|
191
|
+
rGoodTemperature
|
|
192
|
+
rGoodCondition
|
|
193
|
+
rState
|
|
194
|
+
createAt
|
|
195
|
+
updateAt
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
168
199
|
export const CREATE_LOGO = gql`
|
|
169
|
-
mutation setALogoStore($logo: Upload, $idStore: ID) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
200
|
+
mutation setALogoStore($logo: Upload, $idStore: ID) {
|
|
201
|
+
setALogoStore(logo: $logo, idStore: $idStore) {
|
|
202
|
+
success
|
|
203
|
+
message
|
|
204
|
+
}
|
|
173
205
|
}
|
|
174
|
-
|
|
175
|
-
`
|
|
206
|
+
`;
|
|
176
207
|
export const CREATE_BANNER_STORE = gql`
|
|
177
|
-
mutation registerBanner($input: IBanner) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
`
|
|
208
|
+
mutation registerBanner($input: IBanner) {
|
|
209
|
+
registerBanner(input: $input) {
|
|
210
|
+
success
|
|
211
|
+
message
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
185
215
|
export const DELETE_ONE_LOGO_STORE = gql`
|
|
186
216
|
mutation deleteALogoStore($idStore: ID, $Image: String) {
|
|
187
|
-
|
|
217
|
+
deleteALogoStore(idStore: $idStore, Image: $Image) {
|
|
188
218
|
message
|
|
189
219
|
success
|
|
220
|
+
}
|
|
190
221
|
}
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
`
|
|
222
|
+
`;
|
|
194
223
|
export const GET_ONE_BANNER_STORE = gql`
|
|
195
|
-
query getOneBanners($idStore: ID, $id: ID) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
224
|
+
query getOneBanners($idStore: ID, $id: ID) {
|
|
225
|
+
getOneBanners(idStore: $idStore, id: $id) {
|
|
226
|
+
bnId
|
|
227
|
+
id
|
|
228
|
+
path
|
|
229
|
+
bnImageFileName
|
|
230
|
+
idStore
|
|
231
|
+
bnState
|
|
232
|
+
createAt
|
|
233
|
+
updateAt
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
`;
|
|
208
237
|
export const DELETE_ONE_BANNER_STORE = gql`
|
|
209
|
-
mutation DeleteOneBanner(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
238
|
+
mutation DeleteOneBanner(
|
|
239
|
+
$bnState: Int
|
|
240
|
+
$idStore: ID
|
|
241
|
+
$bnId: ID
|
|
242
|
+
$bnImage: String
|
|
243
|
+
$bnImageFileName: String
|
|
244
|
+
) {
|
|
245
|
+
DeleteOneBanner(
|
|
246
|
+
bnState: $bnState
|
|
247
|
+
idStore: $idStore
|
|
248
|
+
bnId: $bnId
|
|
249
|
+
bnImage: $bnImage
|
|
250
|
+
bnImageFileName: $bnImageFileName
|
|
251
|
+
) {
|
|
252
|
+
success
|
|
253
|
+
message
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export const useLazyScript = (src, delay = null) => {
|
|
4
|
-
const [status, setStatus] =
|
|
4
|
+
const [status, setStatus] = useState(src ? 'loading' : 'idle');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
useEffect(() => {
|
|
7
7
|
if (!src) {
|
|
8
8
|
setStatus('idle');
|
|
9
9
|
return 'idle';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useApolloClient } from '@apollo/client';
|
|
2
|
+
import { useState, useCallback } from 'react'
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { Cookies } from '../../cookies';
|
|
5
|
+
|
|
6
|
+
export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
7
|
+
const [loading, setLoading] = useState(false)
|
|
8
|
+
const [error, setError] = useState(false)
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
const client = useApolloClient();
|
|
11
|
+
|
|
12
|
+
const onClickLogout = async () => {
|
|
13
|
+
setLoading(true)
|
|
14
|
+
await window
|
|
15
|
+
.fetch(`${process.env.URL_BASE}api/auth/logout/`, {})
|
|
16
|
+
.then(res => {
|
|
17
|
+
if (res) {
|
|
18
|
+
localStorage.removeItem('session');
|
|
19
|
+
localStorage.removeItem('usuario');
|
|
20
|
+
localStorage.removeItem('location');
|
|
21
|
+
localStorage.removeItem('sessionGoogle');
|
|
22
|
+
localStorage.removeItem('longitude');
|
|
23
|
+
localStorage.removeItem('latitude');
|
|
24
|
+
localStorage.removeItem('restaurant');
|
|
25
|
+
Cookies.remove('vp.store');
|
|
26
|
+
Cookies.remove('app.cart.sales');
|
|
27
|
+
Cookies.remove('restaurant');
|
|
28
|
+
client?.clearStore();
|
|
29
|
+
router.replace('/entrar');
|
|
30
|
+
setLoading(false);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.catch(() => {
|
|
34
|
+
setError(true)
|
|
35
|
+
setAlertBox({ message: 'Ocurrió un error al cerrar session' })
|
|
36
|
+
})
|
|
37
|
+
setLoading(false)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [onClickLogout, { loading, error }]
|
|
41
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { useQuery } from '@apollo/client'
|
|
3
|
+
import {
|
|
4
|
+
useState
|
|
5
|
+
} from 'react'
|
|
6
|
+
import { GET_ALL_PEDIDOS, GET_ALL_PEDIDOS_FROM_STORE } from './queries'
|
|
7
|
+
|
|
8
|
+
export const useOrders = ({
|
|
9
|
+
refetchWritePolicy = 'merge',
|
|
10
|
+
refetchReadPolicy,
|
|
11
|
+
refetch,
|
|
12
|
+
statusOrder,
|
|
13
|
+
fromDate,
|
|
14
|
+
toDate,
|
|
15
|
+
nextFetchPolicy = 'cache-first',
|
|
16
|
+
fetchPolicy = 'cache-and-network',
|
|
17
|
+
pollInterval = 60000,
|
|
18
|
+
onError
|
|
19
|
+
}) => {
|
|
20
|
+
const { data, loading, error, fetchMore } = useQuery(GET_ALL_PEDIDOS, {
|
|
21
|
+
notifyOnNetworkStatusChange: true,
|
|
22
|
+
refetchWritePolicy: refetchWritePolicy,
|
|
23
|
+
pollInterval,
|
|
24
|
+
fetchPolicy,
|
|
25
|
+
refetch,
|
|
26
|
+
refetchReadPolicy,
|
|
27
|
+
nextFetchPolicy: nextFetchPolicy,
|
|
28
|
+
onError: onError
|
|
29
|
+
? onError
|
|
30
|
+
: () => {
|
|
31
|
+
return
|
|
32
|
+
},
|
|
33
|
+
variables: {
|
|
34
|
+
statusOrder: statusOrder,
|
|
35
|
+
fromDate,
|
|
36
|
+
toDate
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
return [
|
|
41
|
+
data?.getAllPedidoStoreFinal,
|
|
42
|
+
{ loading, error, data, fetchMore }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const useOrdersFromStore = ({
|
|
47
|
+
idStore,
|
|
48
|
+
cId,
|
|
49
|
+
dId,
|
|
50
|
+
ctId,
|
|
51
|
+
search = '',
|
|
52
|
+
min,
|
|
53
|
+
fromDate,
|
|
54
|
+
toDate,
|
|
55
|
+
max,
|
|
56
|
+
statusOrder
|
|
57
|
+
}) => {
|
|
58
|
+
const {
|
|
59
|
+
data,
|
|
60
|
+
loading,
|
|
61
|
+
error,
|
|
62
|
+
called
|
|
63
|
+
} = useQuery(GET_ALL_PEDIDOS_FROM_STORE, {
|
|
64
|
+
variables: {
|
|
65
|
+
idStore,
|
|
66
|
+
cId,
|
|
67
|
+
dId,
|
|
68
|
+
ctId,
|
|
69
|
+
search,
|
|
70
|
+
min,
|
|
71
|
+
fromDate,
|
|
72
|
+
toDate,
|
|
73
|
+
max,
|
|
74
|
+
statusOrder
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return [data?.getAllOrdersFromStore || [], { loading: called ? false: loading, error }];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export * from './queries'
|