npm-pkg-hook 1.0.6 → 1.0.8

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/config/client/errors.js +24 -0
  3. package/src/config/client/index.js +1 -0
  4. package/src/hooks/index.js +4 -0
  5. package/src/hooks/useCatWithProduct/index.js +2 -0
  6. package/src/hooks/useCatWithProduct/queries.js +8 -7
  7. package/src/hooks/useCategoryInStore/index.js +1 -0
  8. package/src/hooks/useClients/index.js +63 -13
  9. package/src/hooks/useClients/queries.js +10 -1
  10. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +9 -2
  11. package/src/hooks/useCreateProduct/index.js +19 -6
  12. package/src/hooks/useEmployee/index.js +13 -0
  13. package/src/hooks/useEmployee/queries.js +17 -0
  14. package/src/hooks/useFormTools/index.js +22 -8
  15. package/src/hooks/useFormatDate/index.js +1 -1
  16. package/src/hooks/useImagesStore/queries.js +213 -173
  17. package/src/hooks/useLazyScript/index.js +3 -3
  18. package/src/hooks/useLogout/index.js +41 -0
  19. package/src/hooks/useProductsFood/index.js +3 -3
  20. package/src/hooks/useProductsFood/queriesStore.js +632 -526
  21. package/src/hooks/useProductsFood/usetagsProducts.js +22 -10
  22. package/src/hooks/useReport/queries.js +2 -1
  23. package/src/hooks/useSales/index.js +256 -155
  24. package/src/hooks/useSales/queries.js +348 -198
  25. package/src/hooks/useSales/useGetSale.js +9 -8
  26. package/src/hooks/useSales/useTotalSales.js +10 -3
  27. package/src/hooks/useSetSession/index.js +21 -0
  28. package/src/hooks/useStore/index.js +42 -13
  29. package/src/hooks/useStoreContacts/index.js +47 -0
  30. package/src/hooks/useStoreContacts/queries.js +48 -0
  31. package/src/hooks/useUser/index.js +6 -1
  32. package/src/hooks/useUser/queries.js +18 -0
  33. package/src/utils/index.js +46 -9
@@ -1,101 +1,120 @@
1
- import { gql } from '@apollo/client'
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
- success
7
- message
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
- 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
- `
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
- 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
- `
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
- getAllCatOfProducts(idStore: $idStore) {
37
- id
38
- cpId
39
- catName
40
- catDescription
41
- schState
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 updatedProducts($input: InputCatProducts){
48
- updatedProducts(input: $input){
49
- success
50
- message
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
- createOneContract(input: $input) {
57
- success
58
- message
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 ($umId: ID, $cId: ID, $aId: ID){
64
- employees(umId: $umId, cId: $cId, aId: $aId) {
65
- eId
66
- idStore
67
- id
68
- idEmployee
69
- eSalary
70
- typeContract
71
- uEmail
72
- termContract
73
- eDatAdm
74
- eState
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($search: String, $min: Int, $max: Int, $gender: [String], $pState: Int, $desc: [String], $categories: [ID], $fromDate: DateTime, $toDate: DateTime ) {
80
- productFoodsAll(search: $search, min: $min, max: $max, gender: $gender, desc: $desc, pState: $pState categories: $categories, toDate: $toDate, fromDate: $fromDate) {
81
- pId
82
- sizeId #Talla
83
- colorId #Color
84
- cId #Country
85
- dId #Department
86
- ctId #Cuidad
87
- fId #Características
88
- pName
89
- ProPrice
90
- ProDescuento
91
- free
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
- sTateLogistic
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
- pDatCre
107
- pDatMod
125
+ pDatCre
126
+ pDatMod
108
127
  ProDelivery
109
128
  ProVoltaje
110
- pState
111
- feat {
112
- fId
113
- thpId
114
- hpqrQuestion
115
- }
116
- area {
117
- aId
118
- aName
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
- rSId
129
- rScore
130
- idStore
131
- createAt
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($idStore: ID, $search: String, $min: Int, $max: Int, $fromDate: DateTime, $toDate: DateTime) {
137
- getAllVisitorStore(idStore: $idStore, search: $search, min: $min, max: $max, fromDate: $fromDate, toDate: $toDate) {
138
- visitStoreId
139
- id
140
- idStore
141
- createAt
142
- updateAt
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
- getAllRating(idStore: $idStore){
155
- idStore
156
- rId
157
- id
158
- rAppearance
159
- rTasty
160
- rGoodTemperature
161
- rGoodCondition
162
- rState
163
- createAt
164
- updateAt
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
- setALogoStore(logo: $logo, idStore: $idStore) {
171
- success
172
- message
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
- registerBanner(input: $input) {
179
- success
180
- message
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
- deleteALogoStore(idStore: $idStore, Image: $Image) {
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
- getOneBanners(idStore: $idStore, id: $id) {
197
- bnId
198
- id
199
- path
200
- bnImageFileName
201
- idStore
202
- bnState
203
- createAt
204
- updateAt
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($bnState: Int, $idStore: ID, $bnId: ID, $bnImage: String, $bnImageFileName: String) {
210
- DeleteOneBanner(bnState: $bnState, idStore: $idStore, bnId: $bnId, bnImage: $bnImage, bnImageFileName: $bnImageFileName ) {
211
- success
212
- message
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] = React.useState(src ? 'loading' : 'idle');
4
+ const [status, setStatus] = useState(src ? 'loading' : 'idle');
5
5
 
6
- React.useEffect(() => {
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
+ }
@@ -3,7 +3,7 @@ import {
3
3
  useMutation,
4
4
  useQuery
5
5
  } from '@apollo/client'
6
- import { useEffect, useState } from 'react'
6
+ import { useState } from 'react'
7
7
  import {
8
8
  GET_ALL_EXTRA_PRODUCT,
9
9
  GET_ALL_PRODUCT_STORE,
@@ -40,7 +40,7 @@ export const useProductsFood = ({
40
40
  }) => {
41
41
  // const [productsFood, setProductsFood] = useState([])
42
42
  const [showMore, setShowMore] = useState(50)
43
- const { data, loading, fetchMore, error } = useQuery(GET_ALL_PRODUCT_STORE, {
43
+ const { data, loading, fetchMore, error, called } = useQuery(GET_ALL_PRODUCT_STORE, {
44
44
  fetchPolicy: fetchPolicy ?? 'cache-and-network',
45
45
  notifyOnNetworkStatusChange: true,
46
46
  nextFetchPolicy: 'cache-first',
@@ -63,7 +63,7 @@ export const useProductsFood = ({
63
63
  return [
64
64
  productsFood, {
65
65
  error,
66
- loading,
66
+ loading: called ? false : loading,
67
67
  showMore,
68
68
  fetchMore,
69
69
  setShowMore