npm-pkg-hook 1.1.4 → 1.1.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 +19 -113
- package/.eslintrc.json +127 -108
- package/next.config.js +2 -5
- package/package.json +28 -24
- 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/useLogout/index.js +23 -23
- 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
|
@@ -1,72 +1,71 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
export const useLazyScript = (src, delay = null) => {
|
|
4
|
-
const [status, setStatus] = useState(src ? 'loading' : 'idle')
|
|
4
|
+
const [status, setStatus] = useState(src ? 'loading' : 'idle')
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
if (!src) {
|
|
8
|
-
setStatus('idle')
|
|
9
|
-
return 'idle'
|
|
8
|
+
setStatus('idle')
|
|
9
|
+
return 'idle'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
let script = document.querySelector(`script[src='${src}']`)
|
|
13
|
-
let timeout = null
|
|
12
|
+
let script = document.querySelector(`script[src='${src}']`)
|
|
13
|
+
let timeout = null
|
|
14
14
|
|
|
15
15
|
if (!script) {
|
|
16
16
|
if (delay) {
|
|
17
17
|
timeout = setTimeout(() => {
|
|
18
|
-
injectScript()
|
|
18
|
+
injectScript()
|
|
19
19
|
// Add event listener after the script is added
|
|
20
|
-
script.addEventListener('load', setStateStatus)
|
|
21
|
-
script.addEventListener('error', setStateStatus)
|
|
22
|
-
}, delay)
|
|
20
|
+
script.addEventListener('load', setStateStatus)
|
|
21
|
+
script.addEventListener('error', setStateStatus)
|
|
22
|
+
}, delay)
|
|
23
23
|
} else {
|
|
24
|
-
injectScript()
|
|
24
|
+
injectScript()
|
|
25
25
|
}
|
|
26
26
|
} else {
|
|
27
|
-
setStatus(script.getAttribute('data-status'))
|
|
27
|
+
setStatus(script.getAttribute('data-status'))
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const setStateStatus = (event) => {
|
|
31
|
-
setStatus(event.type === 'load' ? 'ready' : 'error')
|
|
32
|
-
}
|
|
31
|
+
setStatus(event.type === 'load' ? 'ready' : 'error')
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
//code to inject script
|
|
35
|
-
function injectScript() {
|
|
36
|
-
script = document.createElement('script')
|
|
37
|
-
script.src = src
|
|
38
|
-
script.async = true
|
|
39
|
-
script.setAttribute('data-status', 'loading')
|
|
40
|
-
document.body.appendChild(script)
|
|
34
|
+
// code to inject script
|
|
35
|
+
function injectScript () {
|
|
36
|
+
script = document.createElement('script')
|
|
37
|
+
script.src = src
|
|
38
|
+
script.async = true
|
|
39
|
+
script.setAttribute('data-status', 'loading')
|
|
40
|
+
document.body.appendChild(script)
|
|
41
41
|
|
|
42
42
|
const setDataStatus = (event) => {
|
|
43
43
|
script.setAttribute(
|
|
44
44
|
'data-status',
|
|
45
45
|
event.type === 'load' ? 'ready' : 'error'
|
|
46
|
-
)
|
|
47
|
-
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
script.addEventListener('load', setDataStatus)
|
|
50
|
-
script.addEventListener('error', setDataStatus)
|
|
49
|
+
script.addEventListener('load', setDataStatus)
|
|
50
|
+
script.addEventListener('error', setDataStatus)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (script) {
|
|
54
|
-
//script will be be undefined available when its delayed hence check it before adding listener
|
|
55
|
-
script.addEventListener('load', setStateStatus)
|
|
56
|
-
script.addEventListener('error', setStateStatus)
|
|
54
|
+
// script will be be undefined available when its delayed hence check it before adding listener
|
|
55
|
+
script.addEventListener('load', setStateStatus)
|
|
56
|
+
script.addEventListener('error', setStateStatus)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
return () => {
|
|
60
60
|
if (script) {
|
|
61
|
-
script.removeEventListener('load', setStateStatus)
|
|
62
|
-
script.removeEventListener('error', setStateStatus)
|
|
61
|
+
script.removeEventListener('load', setStateStatus)
|
|
62
|
+
script.removeEventListener('error', setStateStatus)
|
|
63
63
|
}
|
|
64
64
|
if (timeout) {
|
|
65
|
-
clearTimeout(timeout)
|
|
65
|
+
clearTimeout(timeout)
|
|
66
66
|
}
|
|
67
|
-
}
|
|
68
|
-
}, [src])
|
|
69
|
-
|
|
70
|
-
return status;
|
|
71
|
-
};
|
|
67
|
+
}
|
|
68
|
+
}, [src])
|
|
72
69
|
|
|
70
|
+
return status
|
|
71
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
export const useLocalStorage= (key, initialValue) => {
|
|
3
|
+
export const useLocalStorage = (key, initialValue) => {
|
|
4
4
|
// const { setAlertBox } = useContext(Context)
|
|
5
5
|
// State to store our value
|
|
6
6
|
// Pass initial state function to useState so logic is only executed once
|
|
@@ -33,4 +33,4 @@ export const useLocalStorage= (key, initialValue) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return [storedValue, setValue]
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useApolloClient } from '@apollo/client'
|
|
2
|
-
import { useState
|
|
3
|
-
import { useRouter } from 'next/router'
|
|
4
|
-
import { Cookies } from '../../cookies'
|
|
1
|
+
import { useApolloClient } from '@apollo/client'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import { useRouter } from 'next/router'
|
|
4
|
+
import { Cookies } from '../../cookies'
|
|
5
5
|
|
|
6
|
-
export const useLogout = ({ setAlertBox = () => {
|
|
6
|
+
export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
7
7
|
const [loading, setLoading] = useState(false)
|
|
8
8
|
const [error, setError] = useState(false)
|
|
9
|
-
const router = useRouter()
|
|
10
|
-
const client = useApolloClient()
|
|
9
|
+
const router = useRouter()
|
|
10
|
+
const client = useApolloClient()
|
|
11
11
|
|
|
12
12
|
const onClickLogout = async () => {
|
|
13
13
|
setLoading(true)
|
|
@@ -15,21 +15,21 @@ export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
|
15
15
|
.fetch(`${process.env.URL_BASE}api/auth/logout/`, {})
|
|
16
16
|
.then(res => {
|
|
17
17
|
if (res) {
|
|
18
|
-
localStorage.removeItem('session')
|
|
19
|
-
localStorage.removeItem('usuario')
|
|
20
|
-
localStorage.removeItem('location')
|
|
21
|
-
localStorage.removeItem('sessionGoogle')
|
|
22
|
-
localStorage.removeItem('namefood')
|
|
23
|
-
localStorage.removeItem('longitude')
|
|
24
|
-
localStorage.removeItem('latitude')
|
|
25
|
-
localStorage.removeItem('userlogin')
|
|
26
|
-
localStorage.removeItem('restaurant')
|
|
27
|
-
Cookies.remove('vp.store')
|
|
28
|
-
Cookies.remove('app.cart.sales')
|
|
29
|
-
Cookies.remove('restaurant')
|
|
30
|
-
client?.clearStore()
|
|
31
|
-
router.replace('/entrar')
|
|
32
|
-
setLoading(false)
|
|
18
|
+
localStorage.removeItem('session')
|
|
19
|
+
localStorage.removeItem('usuario')
|
|
20
|
+
localStorage.removeItem('location')
|
|
21
|
+
localStorage.removeItem('sessionGoogle')
|
|
22
|
+
localStorage.removeItem('namefood')
|
|
23
|
+
localStorage.removeItem('longitude')
|
|
24
|
+
localStorage.removeItem('latitude')
|
|
25
|
+
localStorage.removeItem('userlogin')
|
|
26
|
+
localStorage.removeItem('restaurant')
|
|
27
|
+
Cookies.remove('vp.store')
|
|
28
|
+
Cookies.remove('app.cart.sales')
|
|
29
|
+
Cookies.remove('restaurant')
|
|
30
|
+
client?.clearStore()
|
|
31
|
+
router.replace('/entrar')
|
|
32
|
+
setLoading(false)
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
.catch(() => {
|
|
@@ -40,4 +40,4 @@ export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return [onClickLogout, { loading, error }]
|
|
43
|
-
}
|
|
43
|
+
}
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { useRouter } from 'next/router'
|
|
2
|
-
// Hola mundo
|
|
3
|
-
export const useManageQueryParams = () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
1
|
+
import { useRouter } from 'next/router'
|
|
2
|
+
// Hola mundo
|
|
3
|
+
export const useManageQueryParams = () => {
|
|
4
|
+
const router = useRouter()
|
|
5
|
+
|
|
6
|
+
const handleQuery = (name, value = '') => {
|
|
7
|
+
router.push(
|
|
8
|
+
{
|
|
9
|
+
query: {
|
|
10
|
+
...router.query,
|
|
11
|
+
[name]: value
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
undefined,
|
|
15
|
+
{ shallow: true }
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const handleCleanQuery = (name, value = '') => {
|
|
20
|
+
router.push(
|
|
21
|
+
{
|
|
22
|
+
query: {
|
|
23
|
+
...router.query,
|
|
24
|
+
[name]: value || ''
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
undefined,
|
|
28
|
+
{ shallow: true }
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
handleQuery,
|
|
34
|
+
handleCleanQuery
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
/* eslint-disable no-void */
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
export const useMobile = (props) => {
|
|
5
|
+
const { callBack = () => { return null } } = props || {}
|
|
6
|
+
const [innerHeight, setInnerHeight] = useState()
|
|
7
|
+
const [innerWidth, setInnerWidth] = useState()
|
|
8
|
+
let isMobile = false
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setInnerHeight(window.innerHeight)
|
|
11
|
+
setInnerWidth(window.innerWidth)
|
|
12
|
+
callBack()
|
|
13
|
+
}, [])
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const handleResize = () => {
|
|
16
|
+
if (!isNaN(window === null || window === void 0 ? void 0 : window.innerHeight) && (window === null || window === void 0 ? void 0 : window.innerHeight) !== innerHeight) {
|
|
17
|
+
setInnerHeight(window.innerHeight)
|
|
18
|
+
}
|
|
19
|
+
if (!isNaN(window.innerWidth) && window.innerWidth !== innerWidth) {
|
|
20
|
+
setInnerWidth(window.innerWidth)
|
|
21
|
+
}
|
|
22
|
+
callBack()
|
|
23
|
+
}
|
|
24
|
+
if (typeof window !== 'undefined') {
|
|
25
|
+
window.addEventListener('resize', handleResize)
|
|
26
|
+
}
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('resize', handleResize)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
if (typeof window !== 'undefined' && /Mobile/i.test((navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor))) {
|
|
32
|
+
isMobile = true
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isMobile,
|
|
36
|
+
innerHeight,
|
|
37
|
+
innerWidth
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -2,36 +2,35 @@ import {
|
|
|
2
2
|
useEffect,
|
|
3
3
|
useRef,
|
|
4
4
|
useState
|
|
5
|
-
} from 'react'
|
|
5
|
+
} from 'react'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const childrenContainerRef = useRef(null);
|
|
7
|
+
export const useMutateHeight = ({ isCollapsed = false }) => {
|
|
8
|
+
const [collapsed, setCollapsed] = useState(isCollapsed)
|
|
9
|
+
const childrenContainerRef = useRef(null)
|
|
11
10
|
|
|
12
11
|
useEffect(() => {
|
|
13
|
-
setCollapsed(isCollapsed)
|
|
12
|
+
setCollapsed(isCollapsed)
|
|
14
13
|
if (childrenContainerRef.current !== null) {
|
|
15
14
|
const height = isCollapsed
|
|
16
15
|
? childrenContainerRef.current.scrollHeight
|
|
17
|
-
: 0
|
|
18
|
-
childrenContainerRef.current.style.height = `${height}px
|
|
16
|
+
: 0
|
|
17
|
+
childrenContainerRef.current.style.height = `${height}px`
|
|
19
18
|
}
|
|
20
|
-
}, [isCollapsed])
|
|
19
|
+
}, [isCollapsed])
|
|
21
20
|
|
|
22
21
|
const handleCollapsed = visible => {
|
|
23
|
-
setCollapsed(visible)
|
|
22
|
+
setCollapsed(visible)
|
|
24
23
|
if (childrenContainerRef.current !== null) {
|
|
25
|
-
const height = visible ? childrenContainerRef.current.scrollHeight : 0
|
|
26
|
-
childrenContainerRef.current.style.height = `${height}px
|
|
24
|
+
const height = visible ? childrenContainerRef.current.scrollHeight : 0
|
|
25
|
+
childrenContainerRef.current.style.height = `${height}px`
|
|
27
26
|
}
|
|
28
|
-
}
|
|
27
|
+
}
|
|
29
28
|
|
|
30
29
|
return {
|
|
31
30
|
handleCollapsed,
|
|
32
31
|
childrenContainerRef,
|
|
33
32
|
collapsed
|
|
34
|
-
}
|
|
35
|
-
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
// https://codesandbox.io/s/dropdown-navigation-9fx6r?file=/src/Navigation/Navigation.js:357-775
|
|
36
|
+
// https://codesandbox.io/s/dropdown-navigation-9fx6r?file=/src/Navigation/Navigation.js:357-775
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
1
|
import { useQuery } from '@apollo/client'
|
|
3
|
-
import {
|
|
4
|
-
useState
|
|
5
|
-
} from 'react'
|
|
6
2
|
import { GET_ALL_PEDIDOS, GET_ALL_PEDIDOS_FROM_STORE } from './queries'
|
|
7
3
|
|
|
8
4
|
export const useOrders = ({
|
|
@@ -19,19 +15,17 @@ export const useOrders = ({
|
|
|
19
15
|
}) => {
|
|
20
16
|
const { data, loading, error, fetchMore } = useQuery(GET_ALL_PEDIDOS, {
|
|
21
17
|
notifyOnNetworkStatusChange: true,
|
|
22
|
-
refetchWritePolicy
|
|
18
|
+
refetchWritePolicy,
|
|
23
19
|
pollInterval,
|
|
24
20
|
fetchPolicy,
|
|
25
21
|
refetch,
|
|
26
22
|
refetchReadPolicy,
|
|
27
|
-
nextFetchPolicy
|
|
28
|
-
onError: onError
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
},
|
|
23
|
+
nextFetchPolicy,
|
|
24
|
+
onError: onError || (() => {
|
|
25
|
+
|
|
26
|
+
}),
|
|
33
27
|
variables: {
|
|
34
|
-
statusOrder
|
|
28
|
+
statusOrder,
|
|
35
29
|
fromDate,
|
|
36
30
|
toDate
|
|
37
31
|
}
|
|
@@ -73,9 +67,9 @@ export const useOrdersFromStore = ({
|
|
|
73
67
|
max,
|
|
74
68
|
statusOrder
|
|
75
69
|
}
|
|
76
|
-
})
|
|
70
|
+
})
|
|
77
71
|
|
|
78
|
-
return [data?.getAllOrdersFromStore || [], { loading: called ? false: loading, error }]
|
|
79
|
-
}
|
|
72
|
+
return [data?.getAllOrdersFromStore || [], { loading: called ? false : loading, error }]
|
|
73
|
+
}
|
|
80
74
|
|
|
81
|
-
export * from './queries'
|
|
75
|
+
export * from './queries'
|
|
@@ -73,7 +73,7 @@ export const useProductsFood = ({
|
|
|
73
73
|
]
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export const useDeleteProductsFood = ({ sendNotification = () => {
|
|
76
|
+
export const useDeleteProductsFood = ({ sendNotification = () => { } } = {}) => {
|
|
77
77
|
const [updateProductFoods, { data, loading, error }] = useMutation(UPDATE_PRODUCT_FOOD)
|
|
78
78
|
|
|
79
79
|
const handleDelete = product => {
|
|
@@ -84,17 +84,18 @@ export const useDeleteProductsFood = ({ sendNotification = () => { return } } =
|
|
|
84
84
|
pId,
|
|
85
85
|
pState
|
|
86
86
|
}
|
|
87
|
-
},
|
|
87
|
+
},
|
|
88
|
+
update (cache) {
|
|
88
89
|
cache.modify({
|
|
89
90
|
fields: {
|
|
90
|
-
productFoodsAll(dataOld = []) {
|
|
91
|
+
productFoodsAll (dataOld = []) {
|
|
91
92
|
return cache.writeQuery({ query: GET_ALL_PRODUCT_STORE, data: dataOld })
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
})
|
|
95
96
|
cache.modify({
|
|
96
97
|
fields: {
|
|
97
|
-
getCatProductsWithProduct(dataOld = []) {
|
|
98
|
+
getCatProductsWithProduct (dataOld = []) {
|
|
98
99
|
return cache.writeQuery({ query: GET_ALL_CATEGORIES_WITH_PRODUCT, data: dataOld })
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -120,7 +121,6 @@ export const useDeleteProductsFood = ({ sendNotification = () => { return } } =
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
124
|
export const useExtProductFoodsAll = () => {
|
|
125
125
|
const [ExtProductFoodsAll,
|
|
126
126
|
{
|
|
@@ -131,7 +131,7 @@ export const useExtProductFoodsAll = () => {
|
|
|
131
131
|
] = useLazyQuery(GET_ALL_EXTRA_PRODUCT)
|
|
132
132
|
|
|
133
133
|
const handleExtProductFoodsAll = (pId) => {
|
|
134
|
-
ExtProductFoodsAll({
|
|
134
|
+
return ExtProductFoodsAll({
|
|
135
135
|
variables: {
|
|
136
136
|
pId
|
|
137
137
|
}
|
|
@@ -139,20 +139,20 @@ export const useExtProductFoodsAll = () => {
|
|
|
139
139
|
}
|
|
140
140
|
return [handleExtProductFoodsAll,
|
|
141
141
|
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
data: data?.ExtProductFoodsAll || [],
|
|
143
|
+
loading,
|
|
144
|
+
error
|
|
145
145
|
}
|
|
146
146
|
]
|
|
147
147
|
}
|
|
148
|
-
export const useExtProductFoodsOptionalAll = () => {
|
|
149
148
|
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
export const useExtProductFoodsOptionalAll = () => {
|
|
150
|
+
const [ExtProductFoodsOptionalAll,
|
|
151
|
+
{
|
|
152
|
+
data,
|
|
153
|
+
loading,
|
|
154
|
+
error
|
|
155
|
+
}] = useLazyQuery(GET_EXTRAS_PRODUCT_FOOD_OPTIONAL)
|
|
156
156
|
|
|
157
157
|
const handleGetExtProductFood = (pId) => {
|
|
158
158
|
try {
|
|
@@ -167,41 +167,41 @@ const [ExtProductFoodsOptionalAll,
|
|
|
167
167
|
}
|
|
168
168
|
return [handleGetExtProductFood,
|
|
169
169
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
data: data?.ExtProductFoodsOptionalAll || [],
|
|
171
|
+
loading,
|
|
172
|
+
error
|
|
173
|
+
}]
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
export const useGetOneProductsFood = () => {
|
|
176
|
+
export const useGetOneProductsFood = ({ fetchOnlyProduct = false } = {}) => {
|
|
178
177
|
const [productFoodsOne,
|
|
179
178
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}] = useLazyQuery(GET_ONE_PRODUCTS_FOOD)
|
|
179
|
+
data,
|
|
180
|
+
loading,
|
|
181
|
+
error
|
|
182
|
+
}] = useLazyQuery(GET_ONE_PRODUCTS_FOOD)
|
|
184
183
|
const [handleGetExtProductFood, { data: dataOptional }] = useExtProductFoodsOptionalAll()
|
|
185
184
|
const [handleExtProductFoodsAll, { data: dataExtra }] = useExtProductFoodsAll()
|
|
186
|
-
const handleGetOneProduct = (food) => {
|
|
185
|
+
const handleGetOneProduct = async (food) => {
|
|
187
186
|
const { pId } = food
|
|
188
187
|
try {
|
|
189
188
|
productFoodsOne({
|
|
190
189
|
variables: {
|
|
191
|
-
pId
|
|
190
|
+
pId
|
|
192
191
|
}
|
|
193
192
|
})
|
|
194
|
-
handleGetExtProductFood(pId)
|
|
195
|
-
handleExtProductFoodsAll(pId)
|
|
193
|
+
if (!fetchOnlyProduct) handleGetExtProductFood(pId)
|
|
194
|
+
if (!fetchOnlyProduct) handleExtProductFoodsAll(pId)
|
|
196
195
|
} catch (e) {
|
|
197
196
|
console.log(e)
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
|
-
|
|
199
|
+
const handleFunctionQuery = fetchOnlyProduct ? productFoodsOne : handleGetOneProduct
|
|
200
|
+
return [handleFunctionQuery, {
|
|
201
201
|
data: data?.productFoodsOne || {},
|
|
202
202
|
dataExtra,
|
|
203
203
|
dataOptional,
|
|
204
204
|
loading,
|
|
205
|
-
error
|
|
205
|
+
error
|
|
206
206
|
}]
|
|
207
207
|
}
|