npm-pkg-hook 1.0.0 → 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 +14 -0
- package/.eslintrc.json +108 -0
- package/.github/pull_request_template.md +18 -0
- package/.github/workflows/pepeline.yaml +30 -0
- package/README.md +1 -0
- package/jsconfig.json +28 -0
- package/next.config.js +129 -0
- package/package.json +33 -3
- package/src/cookies/index.ts +3 -0
- package/src/hooks/index.js +19 -0
- package/src/hooks/useAcumulateDate/index.js +16 -0
- package/src/hooks/useAnimationText/index.jsx +30 -0
- package/src/hooks/useCategoryStore/index.js +7 -0
- package/src/hooks/useCategoryStore/queries.js +16 -0
- 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 +57 -0
- package/src/hooks/useEvent/index.js +33 -0
- package/src/hooks/useFetchJson/index.js +25 -0
- package/src/hooks/useFetchMoreInteractions/index.jsx +35 -0
- package/src/hooks/useFormTools/index.js +71 -0
- package/src/hooks/useFullScreenMode/index.js +66 -0
- package/src/hooks/useGetCategorieStore/index.js +21 -0
- package/src/hooks/useGetCategorieStore/queries.js +78 -0
- package/src/hooks/useGetProductsFood/index.js +46 -0
- package/src/hooks/useGetProductsFood/queriesStore.js +766 -0
- package/src/hooks/useHover/index.js +29 -0
- package/src/hooks/useInnerHtml/index.js +38 -0
- package/src/hooks/useIntersection/index.js +31 -0
- package/src/hooks/useKeypress/index.js +28 -0
- package/src/hooks/useLocalSorage/index.js +36 -0
- package/src/hooks/useLocationNavigate/index.js +54 -0
- package/src/hooks/useMobile/index.js +38 -0
- package/src/hooks/useRestaurant/index.js +19 -0
- package/src/hooks/useRestaurant/queries.js +70 -0
- package/src/hooks/useSales/index.js +489 -0
- package/src/hooks/useSales/queries.js +230 -0
- package/src/hooks/useSetState/index.js +24 -0
- package/src/hooks/useStore/index.js +18 -0
- package/src/hooks/useStore/queries.js +136 -0
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -0
- package/src/hooks/useUpdateCart/index.js +124 -0
- package/src/hooks/useUser/index.js +3 -0
- package/src/hooks/useWindowSize/index.js +38 -0
- package/src/index.jsx +1 -6
- package/src/utils/index.js +54 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const CREATE_CLIENTS = gql`
|
|
4
|
+
mutation createClients ($input: IClients) {
|
|
5
|
+
createClients(input: $input) {
|
|
6
|
+
cliId
|
|
7
|
+
idStore
|
|
8
|
+
idUser
|
|
9
|
+
clState
|
|
10
|
+
ClientAddress
|
|
11
|
+
clientNumber
|
|
12
|
+
ccClient
|
|
13
|
+
gender
|
|
14
|
+
clientLastName
|
|
15
|
+
clientName
|
|
16
|
+
createAt
|
|
17
|
+
updateAt
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`
|
|
21
|
+
export const DELETE_ONE_CLIENTS = gql`
|
|
22
|
+
mutation deleteClient($cliId: ID, $clState: Int!) {
|
|
23
|
+
deleteClient(cliId: $cliId, clState: $clState) {
|
|
24
|
+
success
|
|
25
|
+
message
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
export const GET_ALL_CLIENTS = gql`
|
|
30
|
+
query getAllClients($idStore: ID, $cId: ID, $dId: ID, $ctId: ID, $search: String, $min: Int, $max: Int, $fromDate: DateTime, $toDate: DateTime ) {
|
|
31
|
+
getAllClients(idStore: $idStore, cId: $cId, dId: $dId, ctId: $ctId, search: $search, min: $min, max: $max, fromDate: $fromDate, toDate: $toDate) {
|
|
32
|
+
cliId
|
|
33
|
+
idStore
|
|
34
|
+
gender
|
|
35
|
+
# idUser
|
|
36
|
+
clState
|
|
37
|
+
clientNumber
|
|
38
|
+
ccClient
|
|
39
|
+
clientLastName
|
|
40
|
+
clientName
|
|
41
|
+
ClientAddress
|
|
42
|
+
createAt
|
|
43
|
+
updateAt
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`
|
|
48
|
+
export const GET_ONE_CLIENT = gql`
|
|
49
|
+
query getOneClients($cliId: ID) {
|
|
50
|
+
getOneClients(cliId: $cliId) {
|
|
51
|
+
cliId
|
|
52
|
+
idStore
|
|
53
|
+
idUser
|
|
54
|
+
clState
|
|
55
|
+
clientNumber
|
|
56
|
+
ClientAddress
|
|
57
|
+
gender
|
|
58
|
+
ccClient
|
|
59
|
+
clientLastName
|
|
60
|
+
clientName
|
|
61
|
+
createAt
|
|
62
|
+
updateAt
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`
|
|
67
|
+
|
|
68
|
+
export const CREATE_SHOPPING_CARD = gql`
|
|
69
|
+
mutation registerShoppingCard($input: IShoppingCard, $idSubArray: IID_SUB_ITEMS){
|
|
70
|
+
registerShoppingCard(input: $input, idSubArray: $idSubArray){
|
|
71
|
+
ShoppingCard
|
|
72
|
+
id
|
|
73
|
+
pId
|
|
74
|
+
subProductsId
|
|
75
|
+
ShoppingCardRefCode
|
|
76
|
+
uuid
|
|
77
|
+
discountCardProduct
|
|
78
|
+
idUser
|
|
79
|
+
cName
|
|
80
|
+
idStore
|
|
81
|
+
cState
|
|
82
|
+
cDatCre
|
|
83
|
+
cDatMod
|
|
84
|
+
csDescription
|
|
85
|
+
cantProducts
|
|
86
|
+
comments
|
|
87
|
+
# idSubArray
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`
|
|
91
|
+
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
92
|
+
mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pCodeRef: String, $change: String, $valueDelivery: Float, $payMethodPState: Int, $pickUp: Int, $totalProductsPrice: Float, $idSubArray: IID_SUB_ITEMS){
|
|
93
|
+
registerSalesStore(input: $input, id: $id, idStore: $idStore, pCodeRef: $pCodeRef, change: $change, valueDelivery: $valueDelivery, payMethodPState: $payMethodPState, pickUp: $pickUp, totalProductsPrice: $totalProductsPrice, idSubArray: $idSubArray){
|
|
94
|
+
ShoppingCard {
|
|
95
|
+
ShoppingCard
|
|
96
|
+
id
|
|
97
|
+
pId
|
|
98
|
+
subProductsId
|
|
99
|
+
ShoppingCardRefCode
|
|
100
|
+
uuid
|
|
101
|
+
discountCardProduct
|
|
102
|
+
idUser
|
|
103
|
+
cName
|
|
104
|
+
idStore
|
|
105
|
+
cState
|
|
106
|
+
cDatCre
|
|
107
|
+
cDatMod
|
|
108
|
+
csDescription
|
|
109
|
+
cantProducts
|
|
110
|
+
comments
|
|
111
|
+
}
|
|
112
|
+
Response {
|
|
113
|
+
success
|
|
114
|
+
message
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useDrag2(ref) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const target = ref.current
|
|
6
|
+
if (!target) return
|
|
7
|
+
const previousOffset = { x: 0, y: 0 }
|
|
8
|
+
let originMouseX
|
|
9
|
+
let originMouseY
|
|
10
|
+
function onMousemove(e) {
|
|
11
|
+
const { pageX, pageY } = e
|
|
12
|
+
const x = pageX - originMouseX + previousOffset.x
|
|
13
|
+
const y = pageY - originMouseY + previousOffset.y
|
|
14
|
+
target.style.transform = `translate(${ x }px, ${ y }px)`
|
|
15
|
+
}
|
|
16
|
+
function onMouseup(e) {
|
|
17
|
+
previousOffset.x += e.pageX - originMouseX
|
|
18
|
+
previousOffset.y += e.pageY - originMouseY
|
|
19
|
+
window.removeEventListener('mousemove', onMousemove)
|
|
20
|
+
window.removeEventListener('mouseup', onMouseup)
|
|
21
|
+
}
|
|
22
|
+
function onMousedown(e) {
|
|
23
|
+
originMouseX = e.pageX
|
|
24
|
+
originMouseY = e.pageY
|
|
25
|
+
window.addEventListener('mousemove', onMousemove)
|
|
26
|
+
window.addEventListener('mouseup', onMouseup)
|
|
27
|
+
}
|
|
28
|
+
target.addEventListener('mousedown', onMousedown)
|
|
29
|
+
return () => {
|
|
30
|
+
target?.removeEventListener('mousedown', onMousedown)
|
|
31
|
+
window?.removeEventListener('mouseup', onMouseup)
|
|
32
|
+
window?.removeEventListener('mousemove', onMousemove)
|
|
33
|
+
}
|
|
34
|
+
}, [ref])
|
|
35
|
+
}
|
|
36
|
+
import { useState } from 'react'
|
|
37
|
+
|
|
38
|
+
export const useDrag = (x, y) => {
|
|
39
|
+
const [move, setMove] = useState(false)
|
|
40
|
+
const [moveTo, setMoveTo] = useState([x, y])
|
|
41
|
+
const moveIcon = e => {
|
|
42
|
+
const xcoord = moveTo[0] + e.movementX
|
|
43
|
+
const ycoord = moveTo[1] + e.movementY
|
|
44
|
+
setMoveTo([xcoord, ycoord])
|
|
45
|
+
}
|
|
46
|
+
const handleMove = e => {
|
|
47
|
+
move && moveIcon(e)
|
|
48
|
+
}
|
|
49
|
+
const handelDown = () => {
|
|
50
|
+
setMove(true)
|
|
51
|
+
}
|
|
52
|
+
const handelUp = () => {
|
|
53
|
+
setMove(false)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { move, moveTo, handelDown, handelUp, handleMove }
|
|
57
|
+
}
|
|
@@ -0,0 +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: callBack });
|
|
23
|
+
return () => {
|
|
24
|
+
off({ eventType, callBack: callBack });
|
|
25
|
+
};
|
|
26
|
+
}, [eventType, callBack]);
|
|
27
|
+
};
|
|
28
|
+
// This function create and dispatch event
|
|
29
|
+
export const useTrigerEvent = () => {
|
|
30
|
+
return {
|
|
31
|
+
trigger
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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>
|
|
35
|
+
}
|
|
@@ -0,0 +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 }]
|
|
71
|
+
}
|
|
@@ -0,0 +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
|
+
`
|
|
66
|
+
export default useFullscreenMode
|
|
@@ -0,0 +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 }]
|
|
21
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
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
|
+
}
|