npm-pkg-hook 1.0.1 → 1.0.2
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/.babelrc +13 -13
- package/.eslintrc.json +107 -107
- package/.github/pull_request_template.md +18 -0
- package/.github/workflows/pepeline.yaml +30 -0
- package/README.md +1 -1
- package/jsconfig.json +27 -27
- package/next.config.js +128 -128
- package/package.json +10 -2
- package/src/cookies/index.ts +3 -3
- package/src/hooks/index.js +19 -15
- package/src/hooks/useAcumulateDate/index.js +15 -15
- package/src/hooks/useAnimationText/index.jsx +29 -29
- package/src/hooks/useCategoryStore/index.js +7 -7
- package/src/hooks/useCategoryStore/queries.js +16 -16
- package/src/hooks/useCheckbox/index.js +114 -0
- package/src/hooks/useClients/index.js +13 -0
- package/src/hooks/useClients/queries.js +118 -0
- package/src/hooks/useDrag/index.js +56 -56
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFetchJson/index.js +24 -24
- package/src/hooks/useFetchMoreInteractions/index.jsx +34 -34
- package/src/hooks/useFormTools/index.js +70 -70
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGetCategorieStore/index.js +20 -20
- package/src/hooks/useGetCategorieStore/queries.js +77 -77
- package/src/hooks/useGetProductsFood/index.js +46 -0
- package/src/hooks/useGetProductsFood/queriesStore.js +766 -0
- package/src/hooks/useHover/index.js +28 -28
- package/src/hooks/useInnerHtml/index.js +37 -37
- package/src/hooks/useIntersection/index.js +30 -30
- package/src/hooks/useKeypress/index.js +27 -27
- package/src/hooks/useLocalSorage/index.js +35 -35
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useMobile/index.js +38 -0
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +69 -69
- package/src/hooks/useSales/index.js +489 -0
- package/src/hooks/useSales/queries.js +230 -0
- package/src/hooks/useSetState/index.js +24 -24
- package/src/hooks/useStore/index.js +18 -0
- package/src/hooks/useStore/queries.js +136 -0
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateCart/index.js +124 -123
- package/src/hooks/useUser/index.js +3 -3
- package/src/hooks/useWindowSize/index.js +37 -37
- package/src/utils/index.js +54 -27
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
useRef
|
|
5
|
-
} from 'react'
|
|
6
|
-
|
|
7
|
-
export const useFetchMoreInteractions = ({ render, fetchMore = true, callback = () => {} }) => {
|
|
8
|
-
const loadingRef = useRef()
|
|
9
|
-
|
|
10
|
-
const useOnScreen = ref => {
|
|
11
|
-
const [isIntersecting, setIsIntersecting] = useState(false)
|
|
12
|
-
|
|
13
|
-
const observer = new IntersectionObserver(
|
|
14
|
-
([entry]) => setIsIntersecting(entry.isIntersecting)
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (ref.current) observer.observe(ref.current)
|
|
19
|
-
// Remove the observer as soon as the component is unmounted
|
|
20
|
-
return () => { observer.disconnect() }
|
|
21
|
-
}, [ref, observer])
|
|
22
|
-
|
|
23
|
-
return isIntersecting
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const isVisible = useOnScreen(loadingRef)
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (isVisible && fetchMore) callback()
|
|
30
|
-
}, [isVisible, callback, fetchMore])
|
|
31
|
-
|
|
32
|
-
return <div ref={loadingRef}>
|
|
33
|
-
{isVisible && fetchMore ? render || <div style={{ background: 'red' }} >Loading...{isVisible && 'lol'}</div> : <></>}
|
|
34
|
-
</div>
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef
|
|
5
|
+
} from 'react'
|
|
6
|
+
|
|
7
|
+
export const useFetchMoreInteractions = ({ render, fetchMore = true, callback = () => {} }) => {
|
|
8
|
+
const loadingRef = useRef()
|
|
9
|
+
|
|
10
|
+
const useOnScreen = ref => {
|
|
11
|
+
const [isIntersecting, setIsIntersecting] = useState(false)
|
|
12
|
+
|
|
13
|
+
const observer = new IntersectionObserver(
|
|
14
|
+
([entry]) => setIsIntersecting(entry.isIntersecting)
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (ref.current) observer.observe(ref.current)
|
|
19
|
+
// Remove the observer as soon as the component is unmounted
|
|
20
|
+
return () => { observer.disconnect() }
|
|
21
|
+
}, [ref, observer])
|
|
22
|
+
|
|
23
|
+
return isIntersecting
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const isVisible = useOnScreen(loadingRef)
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isVisible && fetchMore) callback()
|
|
30
|
+
}, [isVisible, callback, fetchMore])
|
|
31
|
+
|
|
32
|
+
return <div ref={loadingRef}>
|
|
33
|
+
{isVisible && fetchMore ? render || <div style={{ background: 'red' }} >Loading...{isVisible && 'lol'}</div> : <></>}
|
|
34
|
+
</div>
|
|
35
35
|
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCallback,
|
|
3
|
-
useEffect,
|
|
4
|
-
useState
|
|
5
|
-
} from 'react'
|
|
6
|
-
import { validationSubmitHooks } from '../../utils'
|
|
7
|
-
/**
|
|
8
|
-
* @version 0.0.1
|
|
9
|
-
* @description Hook con herramientas de validación y eventos de cambio
|
|
10
|
-
* @return {Array} devuelve la función onChange a ejecutar y el estado de error de cada input
|
|
11
|
-
*/
|
|
12
|
-
export const useFormTools = () => {
|
|
13
|
-
const [dataForm, setDataForm] = useState({})
|
|
14
|
-
const [errorForm, setErrorForm] = useState({})
|
|
15
|
-
const [errorSubmit, setErrorSubmit] = useState(false)
|
|
16
|
-
const [calledSubmit, setCalledSubmit] = useState(false)
|
|
17
|
-
|
|
18
|
-
// Handle Change
|
|
19
|
-
const handleChange = useCallback((e, error) => {
|
|
20
|
-
setDataForm({ ...dataForm, [e.target.name]: e.target.value })
|
|
21
|
-
setErrorForm({ ...errorForm, [e.target.name]: error })
|
|
22
|
-
}, [setDataForm, dataForm, errorForm, setErrorForm])
|
|
23
|
-
|
|
24
|
-
// Forzar datos desde una ventana externa
|
|
25
|
-
const handleForcedData = useCallback(data => {
|
|
26
|
-
setDataForm(data)
|
|
27
|
-
}, [setDataForm])
|
|
28
|
-
|
|
29
|
-
// Forzar datos de error desde una ventana externa
|
|
30
|
-
const setForcedError = useCallback(errors => {
|
|
31
|
-
setErrorForm(errors)
|
|
32
|
-
}, [setErrorForm])
|
|
33
|
-
|
|
34
|
-
// Handle submit, al enviar formulario
|
|
35
|
-
const handleSubmit = useCallback(({ event, action, msgSuccess, msgError, actionAfterSuccess }) => {
|
|
36
|
-
!!event && event.preventDefault()
|
|
37
|
-
setCalledSubmit(true)
|
|
38
|
-
let errSub = false
|
|
39
|
-
|
|
40
|
-
// Valida los errores locales
|
|
41
|
-
for (const x in errorForm) {
|
|
42
|
-
if (errorForm[x]) errSub = true
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// if (errSub) return setErrorSubmit(errSub)
|
|
46
|
-
|
|
47
|
-
// Valida los errores desde el evento
|
|
48
|
-
const errores = validationSubmitHooks(event.target.elements)
|
|
49
|
-
setErrorForm(errores)
|
|
50
|
-
for (const x in errores) {
|
|
51
|
-
if (errores[x]) errSub = true
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Ejecuta la petición si es válido
|
|
55
|
-
if (!errSub && action) {
|
|
56
|
-
action().then(res => {
|
|
57
|
-
if (res) {
|
|
58
|
-
// setAlertBox({ message: msgSuccess || 'Operación exitosa', color: PColor })
|
|
59
|
-
!!actionAfterSuccess && actionAfterSuccess()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}).catch(e => {return console.log({ message: msgError || e?.message || 'Ha ocurrido un error', color: WColor })})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
setErrorSubmit(errSub)
|
|
66
|
-
}, [errorForm, setErrorForm])
|
|
67
|
-
|
|
68
|
-
useEffect(() => {return setCalledSubmit(false)}, [calledSubmit])
|
|
69
|
-
|
|
70
|
-
return [handleChange, handleSubmit, handleForcedData, { dataForm, errorForm, errorSubmit, calledSubmit, setForcedError }]
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState
|
|
5
|
+
} from 'react'
|
|
6
|
+
import { validationSubmitHooks } from '../../utils'
|
|
7
|
+
/**
|
|
8
|
+
* @version 0.0.1
|
|
9
|
+
* @description Hook con herramientas de validación y eventos de cambio
|
|
10
|
+
* @return {Array} devuelve la función onChange a ejecutar y el estado de error de cada input
|
|
11
|
+
*/
|
|
12
|
+
export const useFormTools = () => {
|
|
13
|
+
const [dataForm, setDataForm] = useState({})
|
|
14
|
+
const [errorForm, setErrorForm] = useState({})
|
|
15
|
+
const [errorSubmit, setErrorSubmit] = useState(false)
|
|
16
|
+
const [calledSubmit, setCalledSubmit] = useState(false)
|
|
17
|
+
|
|
18
|
+
// Handle Change
|
|
19
|
+
const handleChange = useCallback((e, error) => {
|
|
20
|
+
setDataForm({ ...dataForm, [e.target.name]: e.target.value })
|
|
21
|
+
setErrorForm({ ...errorForm, [e.target.name]: error })
|
|
22
|
+
}, [setDataForm, dataForm, errorForm, setErrorForm])
|
|
23
|
+
|
|
24
|
+
// Forzar datos desde una ventana externa
|
|
25
|
+
const handleForcedData = useCallback(data => {
|
|
26
|
+
setDataForm(data)
|
|
27
|
+
}, [setDataForm])
|
|
28
|
+
|
|
29
|
+
// Forzar datos de error desde una ventana externa
|
|
30
|
+
const setForcedError = useCallback(errors => {
|
|
31
|
+
setErrorForm(errors)
|
|
32
|
+
}, [setErrorForm])
|
|
33
|
+
|
|
34
|
+
// Handle submit, al enviar formulario
|
|
35
|
+
const handleSubmit = useCallback(({ event, action, msgSuccess, msgError, actionAfterSuccess }) => {
|
|
36
|
+
!!event && event.preventDefault()
|
|
37
|
+
setCalledSubmit(true)
|
|
38
|
+
let errSub = false
|
|
39
|
+
|
|
40
|
+
// Valida los errores locales
|
|
41
|
+
for (const x in errorForm) {
|
|
42
|
+
if (errorForm[x]) errSub = true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// if (errSub) return setErrorSubmit(errSub)
|
|
46
|
+
|
|
47
|
+
// Valida los errores desde el evento
|
|
48
|
+
const errores = validationSubmitHooks(event.target.elements)
|
|
49
|
+
setErrorForm(errores)
|
|
50
|
+
for (const x in errores) {
|
|
51
|
+
if (errores[x]) errSub = true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Ejecuta la petición si es válido
|
|
55
|
+
if (!errSub && action) {
|
|
56
|
+
action().then(res => {
|
|
57
|
+
if (res) {
|
|
58
|
+
// setAlertBox({ message: msgSuccess || 'Operación exitosa', color: PColor })
|
|
59
|
+
!!actionAfterSuccess && actionAfterSuccess()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}).catch(e => {return console.log({ message: msgError || e?.message || 'Ha ocurrido un error', color: WColor })})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setErrorSubmit(errSub)
|
|
66
|
+
}, [errorForm, setErrorForm])
|
|
67
|
+
|
|
68
|
+
useEffect(() => {return setCalledSubmit(false)}, [calledSubmit])
|
|
69
|
+
|
|
70
|
+
return [handleChange, handleSubmit, handleForcedData, { dataForm, errorForm, errorSubmit, calledSubmit, setForcedError }]
|
|
71
71
|
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
3
|
-
|
|
4
|
-
const useFullscreenMode = () => {
|
|
5
|
-
const [isFullscreen, setFullscreen] = useState(false)
|
|
6
|
-
const elementRef = useRef()
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const changeHandler = () => {return setFullscreen(mode => {return !mode})}
|
|
10
|
-
|
|
11
|
-
document.addEventListener('fullscreenchange', changeHandler, false)
|
|
12
|
-
document.addEventListener('mozfullscreenchange', changeHandler, false)
|
|
13
|
-
document.addEventListener('MSFullScreenChange', changeHandler, false)
|
|
14
|
-
document.addEventListener(
|
|
15
|
-
'webkitfullscreenchange',
|
|
16
|
-
changeHandler,
|
|
17
|
-
false
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
return () => {
|
|
21
|
-
document.removeEventListener('fullscreenchange', changeHandler)
|
|
22
|
-
document.removeEventListener('mozfullscreenchange', changeHandler)
|
|
23
|
-
document.removeEventListener('MSFullScreenChange', changeHandler)
|
|
24
|
-
document.removeEventListener(
|
|
25
|
-
'webkitfullscreenchange',
|
|
26
|
-
changeHandler
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
}, [])
|
|
30
|
-
|
|
31
|
-
const goFullscreen = () => {
|
|
32
|
-
if (elementRef.current.requestFullscreen) {
|
|
33
|
-
elementRef.current.requestFullscreen()
|
|
34
|
-
} else if (elementRef.current.mozRequestFullscreen) {
|
|
35
|
-
//Firefox
|
|
36
|
-
elementRef.current.mozRequestFullscreen()
|
|
37
|
-
} else if (elementRef.current.webkitRequestFullscreen) {
|
|
38
|
-
//Chrome, safari, opera
|
|
39
|
-
elementRef.current.webkitRequestFullscreen()
|
|
40
|
-
} else if (elementRef.current.msRequestFullscreen) {
|
|
41
|
-
//IE, edge
|
|
42
|
-
elementRef.current.msRequestFullscreen()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const exitFullScreen = () => {
|
|
47
|
-
if (document.exitFullscreen) {
|
|
48
|
-
document.exitFullscreen()
|
|
49
|
-
} else if (document.mozCancelFullScreen) {
|
|
50
|
-
document.mozCancelFullScreen()
|
|
51
|
-
} else if (document.webkitExitFullscreen) {
|
|
52
|
-
document.webkitExitFullscreen()
|
|
53
|
-
} else if (document.msExitFullscreen) {
|
|
54
|
-
document.msExitFullscreen()
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const ToggleIcon = (
|
|
59
|
-
<Button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
|
|
60
|
-
)
|
|
61
|
-
return [elementRef, ToggleIcon] //Icon, ref
|
|
62
|
-
}
|
|
63
|
-
const Button = styled.button`
|
|
64
|
-
|
|
65
|
-
`
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
const useFullscreenMode = () => {
|
|
5
|
+
const [isFullscreen, setFullscreen] = useState(false)
|
|
6
|
+
const elementRef = useRef()
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const changeHandler = () => {return setFullscreen(mode => {return !mode})}
|
|
10
|
+
|
|
11
|
+
document.addEventListener('fullscreenchange', changeHandler, false)
|
|
12
|
+
document.addEventListener('mozfullscreenchange', changeHandler, false)
|
|
13
|
+
document.addEventListener('MSFullScreenChange', changeHandler, false)
|
|
14
|
+
document.addEventListener(
|
|
15
|
+
'webkitfullscreenchange',
|
|
16
|
+
changeHandler,
|
|
17
|
+
false
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener('fullscreenchange', changeHandler)
|
|
22
|
+
document.removeEventListener('mozfullscreenchange', changeHandler)
|
|
23
|
+
document.removeEventListener('MSFullScreenChange', changeHandler)
|
|
24
|
+
document.removeEventListener(
|
|
25
|
+
'webkitfullscreenchange',
|
|
26
|
+
changeHandler
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
const goFullscreen = () => {
|
|
32
|
+
if (elementRef.current.requestFullscreen) {
|
|
33
|
+
elementRef.current.requestFullscreen()
|
|
34
|
+
} else if (elementRef.current.mozRequestFullscreen) {
|
|
35
|
+
//Firefox
|
|
36
|
+
elementRef.current.mozRequestFullscreen()
|
|
37
|
+
} else if (elementRef.current.webkitRequestFullscreen) {
|
|
38
|
+
//Chrome, safari, opera
|
|
39
|
+
elementRef.current.webkitRequestFullscreen()
|
|
40
|
+
} else if (elementRef.current.msRequestFullscreen) {
|
|
41
|
+
//IE, edge
|
|
42
|
+
elementRef.current.msRequestFullscreen()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const exitFullScreen = () => {
|
|
47
|
+
if (document.exitFullscreen) {
|
|
48
|
+
document.exitFullscreen()
|
|
49
|
+
} else if (document.mozCancelFullScreen) {
|
|
50
|
+
document.mozCancelFullScreen()
|
|
51
|
+
} else if (document.webkitExitFullscreen) {
|
|
52
|
+
document.webkitExitFullscreen()
|
|
53
|
+
} else if (document.msExitFullscreen) {
|
|
54
|
+
document.msExitFullscreen()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ToggleIcon = (
|
|
59
|
+
<Button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
|
|
60
|
+
)
|
|
61
|
+
return [elementRef, ToggleIcon] //Icon, ref
|
|
62
|
+
}
|
|
63
|
+
const Button = styled.button`
|
|
64
|
+
|
|
65
|
+
`
|
|
66
66
|
export default useFullscreenMode
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import { GET_ONE_STORE_IN_CATEGORY } from './queries'
|
|
4
|
-
|
|
5
|
-
export const useGetCategorieStore = ({ catStoreId }) => {
|
|
6
|
-
|
|
7
|
-
const { data: dataCatSto, loading, error } = useQuery(GET_ONE_STORE_IN_CATEGORY, {
|
|
8
|
-
variables: {
|
|
9
|
-
catStore: catStoreId
|
|
10
|
-
},
|
|
11
|
-
onError: () => {
|
|
12
|
-
console.log({ message: '', duration: 5000 })
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
const [categories, setCategorieStore] = useState([])
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
setCategorieStore(dataCatSto?.getOneCatStore || [])
|
|
19
|
-
}, [dataCatSto])
|
|
20
|
-
return [categories, { loading, error }]
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
import { GET_ONE_STORE_IN_CATEGORY } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useGetCategorieStore = ({ catStoreId }) => {
|
|
6
|
+
|
|
7
|
+
const { data: dataCatSto, loading, error } = useQuery(GET_ONE_STORE_IN_CATEGORY, {
|
|
8
|
+
variables: {
|
|
9
|
+
catStore: catStoreId
|
|
10
|
+
},
|
|
11
|
+
onError: () => {
|
|
12
|
+
console.log({ message: '', duration: 5000 })
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
const [categories, setCategorieStore] = useState([])
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setCategorieStore(dataCatSto?.getOneCatStore || [])
|
|
19
|
+
}, [dataCatSto])
|
|
20
|
+
return [categories, { loading, error }]
|
|
21
21
|
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { gql } from "@apollo/client";
|
|
2
|
-
|
|
3
|
-
export const GET_ONE_STORE_IN_CATEGORY = gql`
|
|
4
|
-
query getOneCatStore($catStore: ID){
|
|
5
|
-
getOneCatStore(catStore: $catStore){
|
|
6
|
-
catStore
|
|
7
|
-
idUser
|
|
8
|
-
cName
|
|
9
|
-
cState
|
|
10
|
-
cDatCre
|
|
11
|
-
cPathImage
|
|
12
|
-
cDatMod
|
|
13
|
-
csDescription
|
|
14
|
-
getAllStore {
|
|
15
|
-
idStore
|
|
16
|
-
cId
|
|
17
|
-
id
|
|
18
|
-
dId
|
|
19
|
-
ctId
|
|
20
|
-
catStore
|
|
21
|
-
neighborhoodStore
|
|
22
|
-
Viaprincipal
|
|
23
|
-
storeOwner
|
|
24
|
-
storeName
|
|
25
|
-
emailStore
|
|
26
|
-
storePhone
|
|
27
|
-
socialRaz
|
|
28
|
-
Image
|
|
29
|
-
banner
|
|
30
|
-
documentIdentifier
|
|
31
|
-
uPhoNum
|
|
32
|
-
ULocation
|
|
33
|
-
upLat
|
|
34
|
-
upLon
|
|
35
|
-
uState
|
|
36
|
-
siteWeb
|
|
37
|
-
description
|
|
38
|
-
NitStore
|
|
39
|
-
typeRegiments
|
|
40
|
-
typeContribute
|
|
41
|
-
secVia
|
|
42
|
-
addressStore
|
|
43
|
-
createdAt
|
|
44
|
-
pais {
|
|
45
|
-
cId
|
|
46
|
-
cName
|
|
47
|
-
cCalCod
|
|
48
|
-
cState
|
|
49
|
-
cDatCre
|
|
50
|
-
cDatMod
|
|
51
|
-
}
|
|
52
|
-
city {
|
|
53
|
-
ctId
|
|
54
|
-
dId
|
|
55
|
-
cName
|
|
56
|
-
cState
|
|
57
|
-
cDatCre
|
|
58
|
-
cDatMod
|
|
59
|
-
}
|
|
60
|
-
department {
|
|
61
|
-
dId
|
|
62
|
-
cId
|
|
63
|
-
dName
|
|
64
|
-
dState
|
|
65
|
-
dDatCre
|
|
66
|
-
dDatMod
|
|
67
|
-
}
|
|
68
|
-
getAllRatingStar {
|
|
69
|
-
rSId
|
|
70
|
-
rScore
|
|
71
|
-
idStore
|
|
72
|
-
createAt
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
export const GET_ONE_STORE_IN_CATEGORY = gql`
|
|
4
|
+
query getOneCatStore($catStore: ID){
|
|
5
|
+
getOneCatStore(catStore: $catStore){
|
|
6
|
+
catStore
|
|
7
|
+
idUser
|
|
8
|
+
cName
|
|
9
|
+
cState
|
|
10
|
+
cDatCre
|
|
11
|
+
cPathImage
|
|
12
|
+
cDatMod
|
|
13
|
+
csDescription
|
|
14
|
+
getAllStore {
|
|
15
|
+
idStore
|
|
16
|
+
cId
|
|
17
|
+
id
|
|
18
|
+
dId
|
|
19
|
+
ctId
|
|
20
|
+
catStore
|
|
21
|
+
neighborhoodStore
|
|
22
|
+
Viaprincipal
|
|
23
|
+
storeOwner
|
|
24
|
+
storeName
|
|
25
|
+
emailStore
|
|
26
|
+
storePhone
|
|
27
|
+
socialRaz
|
|
28
|
+
Image
|
|
29
|
+
banner
|
|
30
|
+
documentIdentifier
|
|
31
|
+
uPhoNum
|
|
32
|
+
ULocation
|
|
33
|
+
upLat
|
|
34
|
+
upLon
|
|
35
|
+
uState
|
|
36
|
+
siteWeb
|
|
37
|
+
description
|
|
38
|
+
NitStore
|
|
39
|
+
typeRegiments
|
|
40
|
+
typeContribute
|
|
41
|
+
secVia
|
|
42
|
+
addressStore
|
|
43
|
+
createdAt
|
|
44
|
+
pais {
|
|
45
|
+
cId
|
|
46
|
+
cName
|
|
47
|
+
cCalCod
|
|
48
|
+
cState
|
|
49
|
+
cDatCre
|
|
50
|
+
cDatMod
|
|
51
|
+
}
|
|
52
|
+
city {
|
|
53
|
+
ctId
|
|
54
|
+
dId
|
|
55
|
+
cName
|
|
56
|
+
cState
|
|
57
|
+
cDatCre
|
|
58
|
+
cDatMod
|
|
59
|
+
}
|
|
60
|
+
department {
|
|
61
|
+
dId
|
|
62
|
+
cId
|
|
63
|
+
dName
|
|
64
|
+
dState
|
|
65
|
+
dDatCre
|
|
66
|
+
dDatMod
|
|
67
|
+
}
|
|
68
|
+
getAllRatingStar {
|
|
69
|
+
rSId
|
|
70
|
+
rScore
|
|
71
|
+
idStore
|
|
72
|
+
createAt
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
78
|
`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
import { GET_ALL_PRODUCT_STORE } from './queriesStore'
|
|
4
|
+
|
|
5
|
+
export const useGetProductsFood = ({
|
|
6
|
+
categories,
|
|
7
|
+
desc,
|
|
8
|
+
fetchPolicy = 'network-only',
|
|
9
|
+
fromDate,
|
|
10
|
+
gender,
|
|
11
|
+
max = 50,
|
|
12
|
+
min,
|
|
13
|
+
pState,
|
|
14
|
+
search = null,
|
|
15
|
+
toDate
|
|
16
|
+
}) => {
|
|
17
|
+
const [productsFood, setProductsFood] = useState([])
|
|
18
|
+
const [showMore, setShowMore] = useState(50)
|
|
19
|
+
const { data, loading, fetchMore, error } = useQuery(GET_ALL_PRODUCT_STORE, {
|
|
20
|
+
fetchPolicy: fetchPolicy,
|
|
21
|
+
variables:
|
|
22
|
+
{
|
|
23
|
+
categories: categories || [],
|
|
24
|
+
desc: desc || [],
|
|
25
|
+
fromDate: fromDate || null,
|
|
26
|
+
gender: gender || [],
|
|
27
|
+
max: max || null,
|
|
28
|
+
min: min || null,
|
|
29
|
+
pState: pState || 0,
|
|
30
|
+
search: search ?? search,
|
|
31
|
+
toDate: toDate || null
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setProductsFood(data?.productFoodsAll || [])
|
|
36
|
+
}, [data, productsFood])
|
|
37
|
+
return [
|
|
38
|
+
productsFood, {
|
|
39
|
+
error,
|
|
40
|
+
loading,
|
|
41
|
+
showMore,
|
|
42
|
+
fetchMore,
|
|
43
|
+
setShowMore
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|