npm-pkg-hook 1.1.9 → 1.2.1
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 +11 -9
- package/src/hooks/useAsideCart/index.js +0 -1
- package/src/hooks/useCart/useCart/index.js +2 -3
- package/src/hooks/useCatWithProduct/queries.js +1 -1
- package/src/hooks/useCatWithProductClient/index.js +24 -16
- package/src/hooks/useClients/queries.js +2 -2
- package/src/hooks/useGetMinPrice/index.js +6 -2
- package/src/hooks/useProductsFood/index.js +3 -2
- package/src/hooks/useSales/helpers/index.js +9 -0
- package/src/hooks/useSales/index.js +18 -6
- package/src/hooks/useSales/useGetSale.js +1 -1
- package/src/hooks/useSchedule/index.js +41 -2
- package/src/hooks/useSchedule/queries.js +9 -0
- package/src/hooks/useStore/index.js +46 -52
- package/src/hooks/useStore/queries.js +2 -1
- package/src/hooks/useUser/queries.js +2 -3
package/package.json
CHANGED
|
@@ -2,14 +2,16 @@ import { onError } from '@apollo/client/link/error'
|
|
|
2
2
|
|
|
3
3
|
export const errorHandler = (error) => {
|
|
4
4
|
let logout = null
|
|
5
|
-
if (error) {
|
|
6
|
-
error.errors?.length && error
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
if (error && Array.isArray(error?.errors)) {
|
|
6
|
+
error.errors?.length && error?.errors?.forEach(err => {
|
|
7
|
+
if (err?.extensions) {
|
|
8
|
+
const { code, message: { message } } = err?.extensions || {}
|
|
9
|
+
if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
|
|
10
|
+
logout = true
|
|
11
|
+
return {
|
|
12
|
+
status: 'FORBIDDEN',
|
|
13
|
+
message
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
})
|
|
@@ -21,4 +23,4 @@ export const errorLink = onError(({ graphQLErrors, networkError }) => {
|
|
|
21
23
|
if (graphQLErrors)graphQLErrors.map(({ message, location, path }) => { return console.log(`[GraphQL error]: Message: ${message}, Location: ${location}, Path: ${path}`) })
|
|
22
24
|
|
|
23
25
|
if (networkError) console.log(`[Network error]: ${networkError}`)
|
|
24
|
-
})
|
|
26
|
+
})
|
|
@@ -35,7 +35,6 @@ export const useAsideCart = ({
|
|
|
35
35
|
const [totalProductPrice, setTotalProductPrice] = useState(0)
|
|
36
36
|
|
|
37
37
|
const [dataShoppingCard, { loading }] = useGetCart({ setCountItemProduct })
|
|
38
|
-
console.log({ dataShoppingCard })
|
|
39
38
|
|
|
40
39
|
// Lógica de transformación de los datos
|
|
41
40
|
const result2 = useMemo(() => {
|
|
@@ -149,7 +149,7 @@ export const useCart = ({
|
|
|
149
149
|
setDataOptional(updateOption || [])
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
if (!pId || pId === '') return
|
|
153
153
|
const resultExtra = await handleExtProductFoodsAll(pId)
|
|
154
154
|
const originalArray = resultExtra?.data?.ExtProductFoodsAll
|
|
155
155
|
|
|
@@ -311,7 +311,7 @@ export const useCart = ({
|
|
|
311
311
|
*/
|
|
312
312
|
|
|
313
313
|
const handleAddProducts = async (food) => {
|
|
314
|
-
if (
|
|
314
|
+
if (!food) return
|
|
315
315
|
const idStore = food?.getStore?.idStore
|
|
316
316
|
if (!idStore) {
|
|
317
317
|
return
|
|
@@ -326,7 +326,6 @@ export const useCart = ({
|
|
|
326
326
|
|
|
327
327
|
const refCodePid = RandomCode(20)
|
|
328
328
|
|
|
329
|
-
console.log(isExistItemInShoppingCart)
|
|
330
329
|
const idShoppingCart = isExistItemInShoppingCart?.ShoppingCard
|
|
331
330
|
try {
|
|
332
331
|
const idStore = food?.getStore?.idStore
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { GET_ALL_CATEGORIES_WITH_PRODUCT_CLIENTS } from './queries'
|
|
1
|
+
import { useQuery } from '@apollo/client';
|
|
2
|
+
import { GET_ALL_CATEGORIES_WITH_PRODUCT_CLIENTS } from './queries';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Custom hook to fetch categories with product data.
|
|
6
7
|
*
|
|
7
8
|
* @param {string} idStore - The ID of the store.
|
|
8
|
-
* @returns {object} - The hook result containing data and fetch function.
|
|
9
|
+
* @returns {object} - The hook result containing filtered data, loading state, and fetch function.
|
|
9
10
|
*/
|
|
10
11
|
export const useCatWithProductClient = (idStore) => {
|
|
11
12
|
const { data, loading, error, fetchMore } = useQuery(GET_ALL_CATEGORIES_WITH_PRODUCT_CLIENTS, {
|
|
@@ -16,9 +17,9 @@ export const useCatWithProductClient = (idStore) => {
|
|
|
16
17
|
search: '',
|
|
17
18
|
gender: [],
|
|
18
19
|
desc: [],
|
|
19
|
-
categories: []
|
|
20
|
-
}
|
|
21
|
-
})
|
|
20
|
+
categories: [],
|
|
21
|
+
},
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
const fetchCategories = () => {
|
|
24
25
|
fetchMore({
|
|
@@ -28,21 +29,28 @@ export const useCatWithProductClient = (idStore) => {
|
|
|
28
29
|
search: '',
|
|
29
30
|
gender: [],
|
|
30
31
|
desc: [],
|
|
31
|
-
categories: []
|
|
32
|
+
categories: [],
|
|
32
33
|
},
|
|
33
34
|
updateQuery: (prev, { fetchMoreResult }) => {
|
|
34
|
-
if (!fetchMoreResult) return prev
|
|
35
|
+
if (!fetchMoreResult) return prev;
|
|
35
36
|
return {
|
|
36
37
|
...prev,
|
|
37
|
-
getCatProductsWithProductClient: fetchMoreResult.getCatProductsWithProductClient
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
38
|
+
getCatProductsWithProductClient: fetchMoreResult.getCatProductsWithProductClient,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Utiliza useMemo para memorizar el resultado filtrado
|
|
45
|
+
const filteredData = useMemo(() => {
|
|
46
|
+
return data?.getCatProductsWithProductClient?.filter(
|
|
47
|
+
(category) => category?.productFoodsAll?.length > 0
|
|
48
|
+
) || [];
|
|
49
|
+
}, [data]);
|
|
42
50
|
|
|
43
|
-
return [
|
|
51
|
+
return [filteredData, {
|
|
44
52
|
loading,
|
|
45
53
|
error,
|
|
46
|
-
fetchCategories
|
|
54
|
+
fetchCategories,
|
|
47
55
|
}]
|
|
48
|
-
}
|
|
56
|
+
};
|
|
@@ -98,7 +98,7 @@ mutation registerShoppingCard($input: IShoppingCard, $idSubArray: IID_SUB_ITEMS
|
|
|
98
98
|
}
|
|
99
99
|
`
|
|
100
100
|
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
101
|
-
mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pCodeRef: String, $change:
|
|
101
|
+
mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pCodeRef: String, $change: Int, $valueDelivery: Float, $payMethodPState: Int, $pickUp: Int, $totalProductsPrice: Float, $idSubArray: IID_SUB_ITEMS){
|
|
102
102
|
registerSalesStore(input: $input, id: $id, idStore: $idStore, pCodeRef: $pCodeRef, change: $change, valueDelivery: $valueDelivery, payMethodPState: $payMethodPState, pickUp: $pickUp, totalProductsPrice: $totalProductsPrice, idSubArray: $idSubArray){
|
|
103
103
|
ShoppingCard {
|
|
104
104
|
ShoppingCard
|
|
@@ -124,4 +124,4 @@ mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pC
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
`
|
|
127
|
+
`
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client'
|
|
2
2
|
import { GET_MIN_PEDIDO } from './queries'
|
|
3
3
|
|
|
4
|
-
export const useGetMinPrice = () => {
|
|
5
|
-
const { data, loading, error } = useQuery(GET_MIN_PEDIDO
|
|
4
|
+
export const useGetMinPrice = ({ idStore = '' } = {}) => {
|
|
5
|
+
const { data, loading, error } = useQuery(GET_MIN_PEDIDO, {
|
|
6
|
+
variables: {
|
|
7
|
+
idStore
|
|
8
|
+
}
|
|
9
|
+
})
|
|
6
10
|
|
|
7
11
|
return [data, { loading, error }]
|
|
8
12
|
}
|
|
@@ -84,7 +84,7 @@ export const useDeleteProductsFood = ({ sendNotification = () => { } } = {}) =>
|
|
|
84
84
|
pId,
|
|
85
85
|
pState
|
|
86
86
|
}
|
|
87
|
-
},
|
|
87
|
+
},
|
|
88
88
|
update (cache) {
|
|
89
89
|
cache.modify({
|
|
90
90
|
fields: {
|
|
@@ -131,6 +131,7 @@ export const useExtProductFoodsAll = () => {
|
|
|
131
131
|
] = useLazyQuery(GET_ALL_EXTRA_PRODUCT)
|
|
132
132
|
|
|
133
133
|
const handleExtProductFoodsAll = (pId) => {
|
|
134
|
+
if (!pId) return
|
|
134
135
|
return ExtProductFoodsAll({
|
|
135
136
|
variables: {
|
|
136
137
|
pId
|
|
@@ -146,7 +147,7 @@ export const useExtProductFoodsAll = () => {
|
|
|
146
147
|
]
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
export const useExtProductFoodsOptionalAll = () => {
|
|
150
|
+
export const useExtProductFoodsOptionalAll = () => {
|
|
150
151
|
const [ExtProductFoodsOptionalAll,
|
|
151
152
|
{
|
|
152
153
|
data,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function convertToIntegerOrFloat(numberString) {
|
|
2
|
+
if (!numberString) return 0;
|
|
3
|
+
|
|
4
|
+
// Convierte a número (entero o flotante)
|
|
5
|
+
const numericValue = parseFloat(numberString);
|
|
6
|
+
|
|
7
|
+
return isNaN(numericValue) ? 0 : numericValue; // Maneja valores no numéricos como 0
|
|
8
|
+
}
|
|
9
|
+
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from './queries'
|
|
27
27
|
import { updateExistingOrders } from '../useUpdateExistingOrders'
|
|
28
28
|
import { useGetSale } from './useGetSale'
|
|
29
|
+
import { convertToIntegerOrFloat } from './helpers'
|
|
29
30
|
export * from './useGetAllSales'
|
|
30
31
|
export { GET_ALL_COUNT_SALES } from './queries'
|
|
31
32
|
|
|
@@ -72,7 +73,11 @@ export const useSales = ({
|
|
|
72
73
|
const [_, setFilteredList] = useState([])
|
|
73
74
|
const [delivery, setDelivery] = useState(false)
|
|
74
75
|
const [print, setPrint] = useState(false)
|
|
75
|
-
const [values, setValues] = useState({
|
|
76
|
+
const [values, setValues] = useState({
|
|
77
|
+
comment: '',
|
|
78
|
+
change: '',
|
|
79
|
+
valueDelivery: ''
|
|
80
|
+
})
|
|
76
81
|
const [dataStore] = useStore()
|
|
77
82
|
const { createdAt } = dataStore || {}
|
|
78
83
|
const [code, setCode] = useState(null)
|
|
@@ -261,7 +266,11 @@ export const useSales = ({
|
|
|
261
266
|
return handleChangeNumber(state, action)
|
|
262
267
|
}
|
|
263
268
|
case 'REMOVE_ALL_PRODUCTS':
|
|
264
|
-
setValues({
|
|
269
|
+
setValues({
|
|
270
|
+
comment: '',
|
|
271
|
+
change: '',
|
|
272
|
+
valueDelivery: ''
|
|
273
|
+
})
|
|
265
274
|
return {
|
|
266
275
|
...state,
|
|
267
276
|
PRODUCT: [],
|
|
@@ -362,7 +371,7 @@ export const useSales = ({
|
|
|
362
371
|
const newData = dataOptional.map((el) =>
|
|
363
372
|
el.code === codeCategory ? updatedItem : el
|
|
364
373
|
)
|
|
365
|
-
setDataOptional((
|
|
374
|
+
setDataOptional(() => [...newData])
|
|
366
375
|
}
|
|
367
376
|
}
|
|
368
377
|
|
|
@@ -739,6 +748,7 @@ export const useSales = ({
|
|
|
739
748
|
price: totalProductPrice || 0,
|
|
740
749
|
discount: 0
|
|
741
750
|
})
|
|
751
|
+
|
|
742
752
|
function applyDiscount (percentage) {
|
|
743
753
|
const validateCondition =
|
|
744
754
|
isNaN(percentage) || percentage < 0 || percentage > 100
|
|
@@ -770,17 +780,19 @@ export const useSales = ({
|
|
|
770
780
|
setLoadingSale(true)
|
|
771
781
|
const code = RandomCode(10)
|
|
772
782
|
setCode(code)
|
|
783
|
+
const changeValue = values.change ? convertToIntegerOrFloat(values.change) : null;
|
|
784
|
+
|
|
773
785
|
return registerSalesStore({
|
|
774
786
|
variables: {
|
|
775
787
|
input: finalArrayProduct || [],
|
|
776
788
|
id: values?.cliId,
|
|
777
789
|
pCodeRef: code,
|
|
778
|
-
change:
|
|
779
|
-
valueDelivery:
|
|
790
|
+
change: changeValue,
|
|
791
|
+
valueDelivery: convertToIntegerOrFloat(values.valueDelivery),
|
|
780
792
|
payMethodPState: data.payMethodPState,
|
|
781
793
|
pickUp: 1,
|
|
782
794
|
discount: discount.discount || 0,
|
|
783
|
-
totalProductsPrice: totalProductsPrice || 0
|
|
795
|
+
totalProductsPrice: convertToIntegerOrFloat(totalProductsPrice) || 0
|
|
784
796
|
}
|
|
785
797
|
})
|
|
786
798
|
.then((responseRegisterR) => {
|
|
@@ -4,7 +4,7 @@ import { GET_ONE_SALE } from './queries'
|
|
|
4
4
|
export const useGetSale = () => {
|
|
5
5
|
const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
|
|
6
6
|
return {
|
|
7
|
-
data: data?.getOnePedidoStore,
|
|
7
|
+
data: data?.getOnePedidoStore,
|
|
8
8
|
loading,
|
|
9
9
|
error,
|
|
10
10
|
called,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useQuery, useMutation } from '@apollo/client'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
GET_ONE_SCHEDULE_STORE,
|
|
4
|
+
GET_SCHEDULE_STORE,
|
|
5
|
+
CREATE_STORE_CALENDAR,
|
|
6
|
+
SET_STATUS_ALL_SCHEDULE_STORE
|
|
7
|
+
} from './queries'
|
|
4
8
|
|
|
5
9
|
export const useSchedule = ({ day = null, idStore = '' }) => {
|
|
6
10
|
const {
|
|
@@ -12,6 +16,41 @@ export const useSchedule = ({ day = null, idStore = '' }) => {
|
|
|
12
16
|
return [data?.getOneStoreSchedules, { loading, error }]
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
export const useSetScheduleOpenAll = () => {
|
|
20
|
+
const [setStoreSchedule, { loading, error }] = useMutation(SET_STATUS_ALL_SCHEDULE_STORE, {
|
|
21
|
+
onError: (e) => {
|
|
22
|
+
console.error(e);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const handleSetStoreSchedule = (scheduleOpenAll) => {
|
|
27
|
+
setStoreSchedule({
|
|
28
|
+
variables: {
|
|
29
|
+
scheduleOpenAll: scheduleOpenAll
|
|
30
|
+
}, update: (cache, { data }) => {
|
|
31
|
+
const success = data?.setScheduleOpenAll?.success
|
|
32
|
+
if (success) {
|
|
33
|
+
cache.modify({
|
|
34
|
+
fields: {
|
|
35
|
+
getStore (_, { readField }) {
|
|
36
|
+
const store = readField('getStore')
|
|
37
|
+
const updatedCart = {
|
|
38
|
+
...store,
|
|
39
|
+
scheduleOpenAll: scheduleOpenAll
|
|
40
|
+
}
|
|
41
|
+
return updatedCart
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return [handleSetStoreSchedule, { loading, error }];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
|
|
15
54
|
export const useSchedules = ({ schDay = 1, idStore = '' }) => {
|
|
16
55
|
const {
|
|
17
56
|
data,
|
|
@@ -32,3 +32,12 @@ export const GET_ONE_SCHEDULE_STORE = gql`
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
`
|
|
35
|
+
|
|
36
|
+
export const SET_STATUS_ALL_SCHEDULE_STORE = gql`
|
|
37
|
+
mutation setScheduleOpenAll($scheduleOpenAll: Boolean!) {
|
|
38
|
+
setScheduleOpenAll(scheduleOpenAll: $scheduleOpenAll) {
|
|
39
|
+
success
|
|
40
|
+
message
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`
|
|
@@ -3,74 +3,68 @@ import { useApolloClient, useQuery } from '@apollo/client'
|
|
|
3
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
|
-
|
|
7
6
|
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
7
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
8
|
+
const client = useApolloClient();
|
|
9
|
+
const [onClickLogout, { loading: load }] = useLogout();
|
|
10
|
+
|
|
11
|
+
// Variables para almacenar los datos del store
|
|
12
|
+
const [store, setStore] = useState({});
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [error, setError] = useState(null);
|
|
18
15
|
|
|
19
16
|
// Intentar leer los datos de la caché
|
|
20
|
-
const cachedData = client.readQuery({ query: GET_ONE_STORE })
|
|
17
|
+
const cachedData = client.readQuery({ query: GET_ONE_STORE });
|
|
21
18
|
|
|
22
19
|
useEffect(() => {
|
|
23
20
|
if (cachedData) {
|
|
21
|
+
const array = store ? Object.keys(store) : []
|
|
24
22
|
// Comprobar si los datos de la caché ya están establecidos en el estado
|
|
25
|
-
if (!store ||
|
|
26
|
-
setStore(cachedData.getStore)
|
|
23
|
+
if (!store || Array.isArray(array) && array?.length === 0) {
|
|
24
|
+
setStore(cachedData.getStore);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
}, [cachedData, store])
|
|
27
|
+
}, [cachedData, store]);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
setStore(getStore)
|
|
37
|
-
},
|
|
38
|
-
onError: (err) => {
|
|
39
|
-
if (err.networkError && err.networkError.result) {
|
|
40
|
-
const response = errorHandler(err.networkError.result)
|
|
41
|
-
if (response) {
|
|
42
|
-
onClickLogout()
|
|
43
|
-
}
|
|
29
|
+
if (isClient && !!idStore) {
|
|
30
|
+
const { data, refetch, loading: loadingClient, error: errorStoreClient } = useQuery(GET_ONE_STORE_BY_ID, {
|
|
31
|
+
skip: !isClient,
|
|
32
|
+
variables: {
|
|
33
|
+
idStore
|
|
44
34
|
}
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
// Ejecutar la consulta y almacenarla en la caché
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
client.query({ query: GET_ONE_STORE }).then(() => {
|
|
51
|
-
// Leer la consulta desde la caché
|
|
52
|
-
const cacheData = client.readQuery({ query: GET_ONE_STORE })
|
|
53
|
-
setStore(cacheData?.getStore)
|
|
54
|
-
})
|
|
55
|
-
}, [client])
|
|
35
|
+
});
|
|
56
36
|
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!loading && !error && !cachedData) {
|
|
60
|
-
client.writeQuery({
|
|
61
|
-
query: GET_ONE_STORE,
|
|
62
|
-
data: { getStore: store }
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
}, [loading, error, cachedData, client, store])
|
|
37
|
+
const dataOneStoreClient = !loadingClient ? data?.getOneStore : {};
|
|
66
38
|
|
|
67
|
-
if (isClient) {
|
|
68
|
-
const dataOneStoreClient = !loadingClient ? data?.getOneStore : {}
|
|
69
39
|
return [dataOneStoreClient, {
|
|
70
40
|
refetch,
|
|
71
41
|
loading: loadingClient,
|
|
72
42
|
error: errorStoreClient
|
|
73
|
-
}]
|
|
43
|
+
}];
|
|
44
|
+
} else {
|
|
45
|
+
const { loading: loadingServer, error: errorServer } = useQuery(GET_ONE_STORE, {
|
|
46
|
+
skip: isClient && !idStore,
|
|
47
|
+
variables: {
|
|
48
|
+
idStore
|
|
49
|
+
},
|
|
50
|
+
fetchPolicy: 'cache-first',
|
|
51
|
+
onCompleted: (data) => {
|
|
52
|
+
const { getStore } = data || {};
|
|
53
|
+
setStore(getStore);
|
|
54
|
+
setLoading(false);
|
|
55
|
+
},
|
|
56
|
+
onError: (err) => {
|
|
57
|
+
if (err.networkError && err.networkError.result) {
|
|
58
|
+
const response = errorHandler(err.networkError.result);
|
|
59
|
+
if (response) {
|
|
60
|
+
onClickLogout();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
setError(err);
|
|
64
|
+
setLoading(false);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return [store, { loading: load || loadingServer || loading, error }];
|
|
74
69
|
}
|
|
75
|
-
|
|
76
|
-
}
|
|
70
|
+
};
|
|
@@ -15,6 +15,7 @@ query getStore($id: ID, $idStore: ID){
|
|
|
15
15
|
getStore(id: $id, idStore: $idStore){
|
|
16
16
|
cId
|
|
17
17
|
id
|
|
18
|
+
scheduleOpenAll
|
|
18
19
|
dId
|
|
19
20
|
idStore
|
|
20
21
|
ctId
|
|
@@ -100,7 +101,7 @@ query getOneStore($StoreName: String, $idStore: ID){
|
|
|
100
101
|
dId
|
|
101
102
|
ctId
|
|
102
103
|
catStore
|
|
103
|
-
neighborhoodStore
|
|
104
|
+
neighborhoodStore
|
|
104
105
|
Viaprincipal
|
|
105
106
|
storeOwner
|
|
106
107
|
storeName
|
|
@@ -49,7 +49,7 @@ query getOneUserProfile($id: ID) {
|
|
|
49
49
|
|
|
50
50
|
export const GET_USER = gql`
|
|
51
51
|
query getUser($id: ID){
|
|
52
|
-
|
|
52
|
+
getUser(id: $id ){
|
|
53
53
|
id
|
|
54
54
|
name
|
|
55
55
|
username
|
|
@@ -65,7 +65,6 @@ upLon
|
|
|
65
65
|
upIdeDoc
|
|
66
66
|
siteWeb
|
|
67
67
|
description
|
|
68
|
-
password
|
|
69
68
|
createAt
|
|
70
69
|
role {
|
|
71
70
|
id
|
|
@@ -124,4 +123,4 @@ export const SET_USER_PROFILE = gql`
|
|
|
124
123
|
upZipCode
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
|
-
`
|
|
126
|
+
`
|