npm-pkg-hook 1.3.7 → 1.3.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.
- package/.eslintrc.js +38 -38
- package/.eslintrc.json +127 -127
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/package.json +46 -46
- package/script.txt +6 -6
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -7
- package/src/hooks/getCategoriesWithProduct/index.js +62 -62
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/index.js +155 -155
- package/src/hooks/useAsideCart/queries.js +10 -10
- package/src/hooks/useCart/index.js +2 -2
- package/src/hooks/useCart/queries.js +164 -164
- package/src/hooks/useCart/useCart/helpers/index.js +75 -75
- package/src/hooks/useCart/useCart/index.js +410 -410
- package/src/hooks/useCart/useGetCart/index.js +31 -31
- package/src/hooks/useCatWithProductClient/index.js +56 -56
- package/src/hooks/useCatWithProductClient/queries.js +55 -55
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useChartData/useChartData/index.js +199 -199
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +52 -0
- package/src/hooks/useCreateProduct/index.js +8 -3
- package/src/hooks/useDeleteSubProductOptional/index.js +30 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDevices/index.js +35 -35
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -94
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEditSubProductOptional/queries.js +10 -10
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -19
- package/src/hooks/useFavoriteStores/queries.js +47 -47
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -172
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -14
- package/src/hooks/useGetFoodRecomended/index.js +32 -33
- package/src/hooks/useGetFoodRecomended/queries.js +47 -47
- package/src/hooks/useGetMinPrice/index.js +12 -12
- package/src/hooks/useGetMinPrice/queries.js +7 -7
- package/src/hooks/useGetOneStoreRating/index.js +40 -40
- package/src/hooks/useGetOneStoreRating/queries.js +18 -18
- package/src/hooks/useGoogleLogin/index.js +160 -160
- package/src/hooks/useGoogleLogin/loadScript.js +15 -15
- package/src/hooks/useGoogleLogin/removeScript.js +7 -7
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImagesStore/index.js +5 -4
- package/src/hooks/useInnerHtml/index.js +39 -39
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useLogout/index.js +29 -21
- package/src/hooks/useManageQueryParams/index.js +37 -36
- package/src/hooks/useMobile/index.js +39 -39
- package/src/hooks/useOrderClient/index.js +5 -5
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -12
- 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 -54
- package/src/hooks/useRatingArrayData/queries.js +19 -19
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSchedule/index.js +72 -72
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +43 -43
- package/src/hooks/useScheduleData/index.js +123 -123
- package/src/hooks/useScroll/index.js +56 -56
- package/src/hooks/useScrollRotate/index.js +16 -16
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -101
- package/src/hooks/useStatusOpenStore/index.js +172 -172
- package/src/hooks/useStatusOrdersClient/queries.js +80 -80
- package/src/hooks/useStore/queries.js +163 -163
- package/src/hooks/useStoreCalendar/index.js +5 -5
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -38
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -8
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
export const useDropzone = (
|
|
4
|
-
onDrop,
|
|
5
|
-
dragHandler = {},
|
|
6
|
-
draggingStyle = { border: 'dashed grey 3px' },
|
|
7
|
-
dragOverStyle = {
|
|
8
|
-
border: 'dashed grey 3px'
|
|
9
|
-
}
|
|
10
|
-
) => {
|
|
11
|
-
const ref = useRef(null)
|
|
12
|
-
const [cleanup, setCleanup] = useState(false)
|
|
13
|
-
const [isDragging, setDragging] = useState(false)
|
|
14
|
-
const [dragOver, setDragOver] = useState(false)
|
|
15
|
-
const handle = useMemo(dragHandler, [])
|
|
16
|
-
|
|
17
|
-
const eventListeners = {
|
|
18
|
-
dragenter: e => {
|
|
19
|
-
return handle.dragEnter(e, () => {
|
|
20
|
-
if (!dragOver) setDragOver(true)
|
|
21
|
-
})
|
|
22
|
-
},
|
|
23
|
-
dragleave: e => {
|
|
24
|
-
return handle.dragLeave(e, () => {
|
|
25
|
-
setDragOver(false)
|
|
26
|
-
})
|
|
27
|
-
},
|
|
28
|
-
dragover: handle.dragBegin,
|
|
29
|
-
drop: e => {
|
|
30
|
-
return handle.drop(e, files => {
|
|
31
|
-
if (typeof onDrop === 'function') onDrop(files, e)
|
|
32
|
-
setDragOver(false)
|
|
33
|
-
setDragging(false)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const windowListeners = {
|
|
39
|
-
dragenter: e => {
|
|
40
|
-
return handle.body.dragEnter(e, () => {
|
|
41
|
-
if (!isDragging) setDragging(true)
|
|
42
|
-
})
|
|
43
|
-
},
|
|
44
|
-
dragleave: e => {
|
|
45
|
-
return handle.body.dragLeave(e, () => {
|
|
46
|
-
// eslint-disable-next-line
|
|
47
|
-
if (isDragging) setDragging(false)
|
|
48
|
-
})
|
|
49
|
-
},
|
|
50
|
-
dragend: () => {
|
|
51
|
-
// eslint-disable-next-line
|
|
52
|
-
},
|
|
53
|
-
drop: e => {
|
|
54
|
-
return handle.body.drop(e, () => {
|
|
55
|
-
setDragging(false)
|
|
56
|
-
setDragOver(false)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (ref.current) {
|
|
63
|
-
const { current } = ref
|
|
64
|
-
Object.keys(eventListeners).forEach(key => { return current.addEventListener(key, eventListeners[key]) }
|
|
65
|
-
)
|
|
66
|
-
Object.keys(windowListeners).forEach(key => { return window.addEventListener(key, windowListeners[key]) }
|
|
67
|
-
)
|
|
68
|
-
setCleanup(true)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return () => {
|
|
72
|
-
if (cleanup) {
|
|
73
|
-
const { current } = ref
|
|
74
|
-
if (current) {
|
|
75
|
-
Object.keys(eventListeners).forEach(key => { return current.removeEventListener(key, eventListeners[key]) }
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
Object.keys(windowListeners).forEach(key => { return window.removeEventListener(key, windowListeners[key]) }
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}, [ref, windowListeners, cleanup, eventListeners, isDragging, dragOver])
|
|
83
|
-
|
|
84
|
-
const dropProps = {
|
|
85
|
-
ref,
|
|
86
|
-
style:
|
|
87
|
-
isDragging || dragOver
|
|
88
|
-
? dragOver
|
|
89
|
-
? dragOverStyle
|
|
90
|
-
: draggingStyle
|
|
91
|
-
: undefined
|
|
92
|
-
}
|
|
93
|
-
return { isDragging, dragOver, dropProps }
|
|
94
|
-
}
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useDropzone = (
|
|
4
|
+
onDrop,
|
|
5
|
+
dragHandler = {},
|
|
6
|
+
draggingStyle = { border: 'dashed grey 3px' },
|
|
7
|
+
dragOverStyle = {
|
|
8
|
+
border: 'dashed grey 3px'
|
|
9
|
+
}
|
|
10
|
+
) => {
|
|
11
|
+
const ref = useRef(null)
|
|
12
|
+
const [cleanup, setCleanup] = useState(false)
|
|
13
|
+
const [isDragging, setDragging] = useState(false)
|
|
14
|
+
const [dragOver, setDragOver] = useState(false)
|
|
15
|
+
const handle = useMemo(dragHandler, [])
|
|
16
|
+
|
|
17
|
+
const eventListeners = {
|
|
18
|
+
dragenter: e => {
|
|
19
|
+
return handle.dragEnter(e, () => {
|
|
20
|
+
if (!dragOver) setDragOver(true)
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
dragleave: e => {
|
|
24
|
+
return handle.dragLeave(e, () => {
|
|
25
|
+
setDragOver(false)
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
dragover: handle.dragBegin,
|
|
29
|
+
drop: e => {
|
|
30
|
+
return handle.drop(e, files => {
|
|
31
|
+
if (typeof onDrop === 'function') onDrop(files, e)
|
|
32
|
+
setDragOver(false)
|
|
33
|
+
setDragging(false)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const windowListeners = {
|
|
39
|
+
dragenter: e => {
|
|
40
|
+
return handle.body.dragEnter(e, () => {
|
|
41
|
+
if (!isDragging) setDragging(true)
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
dragleave: e => {
|
|
45
|
+
return handle.body.dragLeave(e, () => {
|
|
46
|
+
// eslint-disable-next-line
|
|
47
|
+
if (isDragging) setDragging(false)
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
dragend: () => {
|
|
51
|
+
// eslint-disable-next-line
|
|
52
|
+
},
|
|
53
|
+
drop: e => {
|
|
54
|
+
return handle.body.drop(e, () => {
|
|
55
|
+
setDragging(false)
|
|
56
|
+
setDragOver(false)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (ref.current) {
|
|
63
|
+
const { current } = ref
|
|
64
|
+
Object.keys(eventListeners).forEach(key => { return current.addEventListener(key, eventListeners[key]) }
|
|
65
|
+
)
|
|
66
|
+
Object.keys(windowListeners).forEach(key => { return window.addEventListener(key, windowListeners[key]) }
|
|
67
|
+
)
|
|
68
|
+
setCleanup(true)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return () => {
|
|
72
|
+
if (cleanup) {
|
|
73
|
+
const { current } = ref
|
|
74
|
+
if (current) {
|
|
75
|
+
Object.keys(eventListeners).forEach(key => { return current.removeEventListener(key, eventListeners[key]) }
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
Object.keys(windowListeners).forEach(key => { return window.removeEventListener(key, windowListeners[key]) }
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, [ref, windowListeners, cleanup, eventListeners, isDragging, dragOver])
|
|
83
|
+
|
|
84
|
+
const dropProps = {
|
|
85
|
+
ref,
|
|
86
|
+
style:
|
|
87
|
+
isDragging || dragOver
|
|
88
|
+
? dragOver
|
|
89
|
+
? dragOverStyle
|
|
90
|
+
: draggingStyle
|
|
91
|
+
: undefined
|
|
92
|
+
}
|
|
93
|
+
return { isDragging, dragOver, dropProps }
|
|
94
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
import { GET_ONE_DYNAMIC_PASS } from './queries'
|
|
4
|
-
|
|
5
|
-
export const useDynamicAuth = () => {
|
|
6
|
-
const [dynamicPass, setDynamicPass] = useState({})
|
|
7
|
-
const { loading, error } = useQuery(GET_ONE_DYNAMIC_PASS, {
|
|
8
|
-
onCompleted: (res) => {
|
|
9
|
-
setDynamicPass(res.getAOneDynamicPassword)
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
return [dynamicPass, { loading, error }]
|
|
13
|
-
}
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import { GET_ONE_DYNAMIC_PASS } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useDynamicAuth = () => {
|
|
6
|
+
const [dynamicPass, setDynamicPass] = useState({})
|
|
7
|
+
const { loading, error } = useQuery(GET_ONE_DYNAMIC_PASS, {
|
|
8
|
+
onCompleted: (res) => {
|
|
9
|
+
setDynamicPass(res.getAOneDynamicPassword)
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
return [dynamicPass, { loading, error }]
|
|
13
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CREATE_ONE_DYNAMIC_PASS = gql`
|
|
4
|
-
mutation registerDynamicPassword($input: IDynamicPassword) {
|
|
5
|
-
registerDynamicPassword(input: $input) {
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`
|
|
11
|
-
export const GET_ONE_DYNAMIC_PASS = gql`
|
|
12
|
-
query getAOneDynamicPassword {
|
|
13
|
-
getAOneDynamicPassword {
|
|
14
|
-
dPassId
|
|
15
|
-
id
|
|
16
|
-
idStore
|
|
17
|
-
keyPassDynamic
|
|
18
|
-
deviceName
|
|
19
|
-
dState
|
|
20
|
-
DatCre
|
|
21
|
-
DatMod
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const CREATE_ONE_DYNAMIC_PASS = gql`
|
|
4
|
+
mutation registerDynamicPassword($input: IDynamicPassword) {
|
|
5
|
+
registerDynamicPassword(input: $input) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
export const GET_ONE_DYNAMIC_PASS = gql`
|
|
12
|
+
query getAOneDynamicPassword {
|
|
13
|
+
getAOneDynamicPassword {
|
|
14
|
+
dPassId
|
|
15
|
+
id
|
|
16
|
+
idStore
|
|
17
|
+
keyPassDynamic
|
|
18
|
+
deviceName
|
|
19
|
+
dState
|
|
20
|
+
DatCre
|
|
21
|
+
DatMod
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const EDIT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
|
|
4
|
-
mutation editExtFoodSubsOptional($opSubExPid: ID, $state: Int, $isCustomSubOpExPid: Boolean, $OptionalSubProName: String){
|
|
5
|
-
editExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state, isCustomSubOpExPid: $isCustomSubOpExPid, OptionalSubProName: $OptionalSubProName){
|
|
6
|
-
success,
|
|
7
|
-
message
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const EDIT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
|
|
4
|
+
mutation editExtFoodSubsOptional($opSubExPid: ID, $state: Int, $isCustomSubOpExPid: Boolean, $OptionalSubProName: String){
|
|
5
|
+
editExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state, isCustomSubOpExPid: $isCustomSubOpExPid, OptionalSubProName: $OptionalSubProName){
|
|
6
|
+
success,
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
export const on = ({ eventType, callBack }) => {
|
|
3
|
-
document.addEventListener(eventType, callBack)
|
|
4
|
-
}
|
|
5
|
-
export const off = ({ eventType, callBack }) => {
|
|
6
|
-
document.removeEventListener(eventType, callBack)
|
|
7
|
-
}
|
|
8
|
-
export const once = ({ eventType, callBack }) => {
|
|
9
|
-
const handleEventOnce = (event) => {
|
|
10
|
-
callBack(event)
|
|
11
|
-
off({ eventType, callBack: handleEventOnce })
|
|
12
|
-
}
|
|
13
|
-
on({ eventType, callBack: handleEventOnce })
|
|
14
|
-
}
|
|
15
|
-
export const trigger = ({ eventType, data }) => {
|
|
16
|
-
const event = new CustomEvent(eventType, { detail: data })
|
|
17
|
-
document.dispatchEvent(event)
|
|
18
|
-
}
|
|
19
|
-
// This function is used to subscribe components an any event
|
|
20
|
-
export const useEvents = ({ eventType, callBack }) => {
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
on({ eventType, callBack })
|
|
23
|
-
return () => {
|
|
24
|
-
off({ eventType, callBack })
|
|
25
|
-
}
|
|
26
|
-
}, [eventType, callBack])
|
|
27
|
-
}
|
|
28
|
-
// This function create and dispatch event
|
|
29
|
-
export const useTrigerEvent = () => {
|
|
30
|
-
return {
|
|
31
|
-
trigger
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
export const on = ({ eventType, callBack }) => {
|
|
3
|
+
document.addEventListener(eventType, callBack)
|
|
4
|
+
}
|
|
5
|
+
export const off = ({ eventType, callBack }) => {
|
|
6
|
+
document.removeEventListener(eventType, callBack)
|
|
7
|
+
}
|
|
8
|
+
export const once = ({ eventType, callBack }) => {
|
|
9
|
+
const handleEventOnce = (event) => {
|
|
10
|
+
callBack(event)
|
|
11
|
+
off({ eventType, callBack: handleEventOnce })
|
|
12
|
+
}
|
|
13
|
+
on({ eventType, callBack: handleEventOnce })
|
|
14
|
+
}
|
|
15
|
+
export const trigger = ({ eventType, data }) => {
|
|
16
|
+
const event = new CustomEvent(eventType, { detail: data })
|
|
17
|
+
document.dispatchEvent(event)
|
|
18
|
+
}
|
|
19
|
+
// This function is used to subscribe components an any event
|
|
20
|
+
export const useEvents = ({ eventType, callBack }) => {
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
on({ eventType, callBack })
|
|
23
|
+
return () => {
|
|
24
|
+
off({ eventType, callBack })
|
|
25
|
+
}
|
|
26
|
+
}, [eventType, callBack])
|
|
27
|
+
}
|
|
28
|
+
// This function create and dispatch event
|
|
29
|
+
export const useTrigerEvent = () => {
|
|
30
|
+
return {
|
|
31
|
+
trigger
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { GET_ALL_FAV_STORE } from './queries'
|
|
3
|
-
|
|
4
|
-
export const useFavoriteStores = () => {
|
|
5
|
-
const {
|
|
6
|
-
data,
|
|
7
|
-
loading,
|
|
8
|
-
error
|
|
9
|
-
} = useQuery(GET_ALL_FAV_STORE, {
|
|
10
|
-
fetchPolicy: 'cache-and-network',
|
|
11
|
-
onError: () => {
|
|
12
|
-
console.log('')
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const favoriteStores = data?.getFavorite || []
|
|
17
|
-
|
|
18
|
-
return [favoriteStores, { loading, error }]
|
|
19
|
-
}
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { GET_ALL_FAV_STORE } from './queries'
|
|
3
|
+
|
|
4
|
+
export const useFavoriteStores = () => {
|
|
5
|
+
const {
|
|
6
|
+
data,
|
|
7
|
+
loading,
|
|
8
|
+
error
|
|
9
|
+
} = useQuery(GET_ALL_FAV_STORE, {
|
|
10
|
+
fetchPolicy: 'cache-and-network',
|
|
11
|
+
onError: () => {
|
|
12
|
+
console.log('')
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const favoriteStores = data?.getFavorite || []
|
|
17
|
+
|
|
18
|
+
return [favoriteStores, { loading, error }]
|
|
19
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const GET_ALL_FAV_STORE = gql`
|
|
4
|
-
query getFavorite{
|
|
5
|
-
getFavorite{
|
|
6
|
-
fIStoreId
|
|
7
|
-
fState
|
|
8
|
-
createAt
|
|
9
|
-
updateAt
|
|
10
|
-
idStore
|
|
11
|
-
|
|
12
|
-
getOneStore {
|
|
13
|
-
idStore
|
|
14
|
-
cId
|
|
15
|
-
id
|
|
16
|
-
Image
|
|
17
|
-
open
|
|
18
|
-
cateStore{
|
|
19
|
-
catStore
|
|
20
|
-
cName
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
ctId
|
|
24
|
-
catStore
|
|
25
|
-
dId
|
|
26
|
-
storeName
|
|
27
|
-
Image
|
|
28
|
-
city{
|
|
29
|
-
ctId
|
|
30
|
-
dId
|
|
31
|
-
cName
|
|
32
|
-
}
|
|
33
|
-
department {
|
|
34
|
-
dId
|
|
35
|
-
cId
|
|
36
|
-
dName
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
pais {
|
|
40
|
-
cId
|
|
41
|
-
cName
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_FAV_STORE = gql`
|
|
4
|
+
query getFavorite{
|
|
5
|
+
getFavorite{
|
|
6
|
+
fIStoreId
|
|
7
|
+
fState
|
|
8
|
+
createAt
|
|
9
|
+
updateAt
|
|
10
|
+
idStore
|
|
11
|
+
|
|
12
|
+
getOneStore {
|
|
13
|
+
idStore
|
|
14
|
+
cId
|
|
15
|
+
id
|
|
16
|
+
Image
|
|
17
|
+
open
|
|
18
|
+
cateStore{
|
|
19
|
+
catStore
|
|
20
|
+
cName
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
ctId
|
|
24
|
+
catStore
|
|
25
|
+
dId
|
|
26
|
+
storeName
|
|
27
|
+
Image
|
|
28
|
+
city{
|
|
29
|
+
ctId
|
|
30
|
+
dId
|
|
31
|
+
cName
|
|
32
|
+
}
|
|
33
|
+
department {
|
|
34
|
+
dId
|
|
35
|
+
cId
|
|
36
|
+
dName
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
pais {
|
|
40
|
+
cId
|
|
41
|
+
cName
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* It fetches a json response, and if the response is not ok, it throws an error with the response and
|
|
3
|
-
* the data
|
|
4
|
-
* @param args - The arguments to pass to fetch.
|
|
5
|
-
*/
|
|
6
|
-
export const fetchJson = async (...args) => {
|
|
7
|
-
try {
|
|
8
|
-
const response = await fetch(...args)
|
|
9
|
-
// if the server replies, there's always some data in json
|
|
10
|
-
// if there's a network error, it will throw at the previous line
|
|
11
|
-
const data = await response.json()
|
|
12
|
-
if (response.ok) {
|
|
13
|
-
return data
|
|
14
|
-
}
|
|
15
|
-
const error = new Error(response.statusText)
|
|
16
|
-
error.response = response
|
|
17
|
-
error.data = data
|
|
18
|
-
throw error
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (!error.data) {
|
|
21
|
-
error.data = { message: error.message }
|
|
22
|
-
}
|
|
23
|
-
throw error
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* It fetches a json response, and if the response is not ok, it throws an error with the response and
|
|
3
|
+
* the data
|
|
4
|
+
* @param args - The arguments to pass to fetch.
|
|
5
|
+
*/
|
|
6
|
+
export const fetchJson = async (...args) => {
|
|
7
|
+
try {
|
|
8
|
+
const response = await fetch(...args)
|
|
9
|
+
// if the server replies, there's always some data in json
|
|
10
|
+
// if there's a network error, it will throw at the previous line
|
|
11
|
+
const data = await response.json()
|
|
12
|
+
if (response.ok) {
|
|
13
|
+
return data
|
|
14
|
+
}
|
|
15
|
+
const error = new Error(response.statusText)
|
|
16
|
+
error.response = response
|
|
17
|
+
error.data = data
|
|
18
|
+
throw error
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (!error.data) {
|
|
21
|
+
error.data = { message: error.message }
|
|
22
|
+
}
|
|
23
|
+
throw error
|
|
24
|
+
}
|
|
25
|
+
}
|