npm-pkg-hook 1.0.2 → 1.0.4
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/.env +1 -0
- package/.eslintrc.js +132 -0
- package/.eslintrc.json +107 -107
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +12 -0
- package/README.md +1 -1
- package/jsconfig.json +27 -27
- package/next.config.js +128 -128
- package/package.json +8 -6
- package/script.txt +7 -0
- package/src/cookies/index.ts +3 -3
- package/src/hooks/index.js +46 -19
- package/src/hooks/updateExtProductFoodsOptional/index.js +38 -0
- package/src/hooks/useAcumulateDate/index.js +16 -16
- package/src/hooks/useAnimationText/index.jsx +31 -30
- package/src/hooks/useBanner/index.js +19 -0
- package/src/hooks/useCatWithProduct/index.js +42 -0
- package/src/hooks/useCatWithProduct/queries.js +172 -0
- package/src/hooks/useCategoryInStore/index.js +94 -0
- package/src/hooks/{useGetCategorieStore → useCategoryInStore}/queries.js +77 -77
- package/src/hooks/useCategoryStore/index.js +7 -7
- package/src/hooks/useCategoryStore/queries.js +16 -16
- package/src/hooks/useChartData/index.js +168 -0
- package/src/hooks/useCheckbox/index.js +114 -114
- package/src/hooks/useClients/index.js +13 -13
- package/src/hooks/useClients/queries.js +117 -117
- package/src/hooks/useConnection/index.js +23 -0
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +165 -0
- package/src/hooks/useCreateProduct/index.js +268 -0
- package/src/hooks/useDessert/index.js +141 -0
- package/src/hooks/useDrag/index.js +62 -57
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFetchJson/index.js +24 -24
- package/src/hooks/useFetchMoreInteractions/index.jsx +37 -34
- package/src/hooks/useFormTools/index.js +83 -70
- package/src/hooks/useFormatDate/index.js +34 -0
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useHover/index.js +28 -28
- package/src/hooks/useImageOptimization/index.js +28 -0
- package/src/hooks/useImageWeight/index.js +52 -0
- package/src/hooks/useImagesStore/index.js +171 -0
- package/src/hooks/useImagesStore/queries.js +216 -0
- package/src/hooks/useInnerHtml/index.js +37 -37
- package/src/hooks/useIntersection/index.js +84 -31
- package/src/hooks/useKeypress/index.js +27 -27
- package/src/hooks/useLazyScript/index.js +72 -0
- package/src/hooks/useLocalSorage/index.js +35 -35
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useMobile/index.js +37 -37
- package/src/hooks/useMutateHeight/index.js +37 -0
- package/src/hooks/useProductsFood/index.js +190 -0
- package/src/hooks/{useGetProductsFood → useProductsFood}/queriesStore.js +780 -765
- package/src/hooks/useProductsFood/usetagsProducts.js +57 -0
- package/src/hooks/useReport/index.js +35 -0
- package/src/hooks/useReport/queries.js +122 -0
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +79 -69
- package/src/hooks/useSales/index.js +589 -489
- package/src/hooks/useSales/queries.js +290 -229
- package/src/hooks/useSales/useGetSale.js +12 -0
- package/src/hooks/useSales/useTotalSales.js +17 -0
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +30 -0
- package/src/hooks/useSaveAvailableProduct/index.js +26 -0
- package/src/hooks/useSaveAvailableProduct/queries.js +10 -0
- package/src/hooks/useSchedule/index.jsx +23 -0
- package/src/hooks/useSetState/index.js +24 -24
- package/src/hooks/useStore/index.js +17 -17
- package/src/hooks/useStore/queries.js +135 -135
- package/src/hooks/useStoreCalendar/index.js +7 -0
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateCart/index.js +124 -124
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +37 -0
- package/src/hooks/useUser/index.js +7 -3
- package/src/hooks/useUser/queries.js +69 -0
- package/src/hooks/useWindowSize/index.js +37 -37
- package/src/index.jsx +2 -1
- package/src/mock/dessert/index.js +16 -0
- package/src/mock/index.js +2 -0
- package/src/utils/index.js +106 -54
- package/src/hooks/useGetCategorieStore/index.js +0 -21
- package/src/hooks/useGetProductsFood/index.js +0 -46
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
import { updateCacheMod } from '../../utils'
|
|
3
|
+
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL } from '../useProductsFood/queriesStore'
|
|
4
|
+
|
|
5
|
+
export const useUpdateExtProductFoodsSubOptional = () => {
|
|
6
|
+
const [updateExtProductFoodsSubOptional] = useMutation(GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL)
|
|
7
|
+
|
|
8
|
+
const handleMutateExtProductFoodsSubOptional = ({
|
|
9
|
+
pId,
|
|
10
|
+
title,
|
|
11
|
+
listId,
|
|
12
|
+
id,
|
|
13
|
+
state = 1,
|
|
14
|
+
}) => {
|
|
15
|
+
updateExtProductFoodsSubOptional({
|
|
16
|
+
variables: {
|
|
17
|
+
input: {
|
|
18
|
+
pId,
|
|
19
|
+
OptionalSubProName: title,
|
|
20
|
+
exCodeOptionExtra: listId,
|
|
21
|
+
exCode: id,
|
|
22
|
+
state
|
|
23
|
+
}
|
|
24
|
+
}, update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
|
|
25
|
+
return updateCacheMod({
|
|
26
|
+
cache,
|
|
27
|
+
query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
28
|
+
nameFun: 'ExtProductFoodsOptionalAll',
|
|
29
|
+
dataNew: ExtProductFoodsOptionalAll
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
handleMutateExtProductFoodsSubOptional
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { GET_USER } from './queries'
|
|
3
|
+
|
|
4
|
+
export const useUser = () => {
|
|
5
|
+
const { data, loading, error } = useQuery(GET_USER)
|
|
6
|
+
return [data?.getUser, { loading, error }]
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const LOGIN = gql`
|
|
4
|
+
mutation login($input: LoginInput){
|
|
5
|
+
login(input: $input){
|
|
6
|
+
token
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`
|
|
10
|
+
export const GET_USER = gql`
|
|
11
|
+
query getUser($id: ID){
|
|
12
|
+
getUser(id: $id ){
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
username
|
|
16
|
+
lastName
|
|
17
|
+
email
|
|
18
|
+
avatar
|
|
19
|
+
uToken
|
|
20
|
+
uPhoNum
|
|
21
|
+
ULocation
|
|
22
|
+
upLat
|
|
23
|
+
uState
|
|
24
|
+
upLon
|
|
25
|
+
upIdeDoc
|
|
26
|
+
siteWeb
|
|
27
|
+
description
|
|
28
|
+
password
|
|
29
|
+
createAt
|
|
30
|
+
role {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
export const GET_ALL_USER = gql`
|
|
38
|
+
query getAllUser($search: String){
|
|
39
|
+
getAllUser(search: $search){
|
|
40
|
+
id
|
|
41
|
+
name
|
|
42
|
+
username
|
|
43
|
+
lastName
|
|
44
|
+
email
|
|
45
|
+
email
|
|
46
|
+
siteWeb
|
|
47
|
+
description
|
|
48
|
+
uPhoNum
|
|
49
|
+
upLat
|
|
50
|
+
upLon
|
|
51
|
+
createAt
|
|
52
|
+
avatar
|
|
53
|
+
latestMessage {
|
|
54
|
+
uuid
|
|
55
|
+
content
|
|
56
|
+
from
|
|
57
|
+
to
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
export const UPDATE_AVATAR = gql`
|
|
63
|
+
mutation updateAvatar($file: Upload){
|
|
64
|
+
UpdateAvatar(file: $file){
|
|
65
|
+
status
|
|
66
|
+
urlAvatar
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
export default function useWindowSize() {
|
|
4
|
-
// Initialize state with undefined width/height so server and client renders match
|
|
5
|
-
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
|
|
6
|
-
const [windowSize, setWindowSize] = useState({
|
|
7
|
-
width: undefined,
|
|
8
|
-
height: undefined
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
// Handler to call on window resize
|
|
13
|
-
function handleResize() {
|
|
14
|
-
// Set window width/height to state
|
|
15
|
-
setWindowSize({
|
|
16
|
-
width: window.innerWidth,
|
|
17
|
-
height: window.innerHeight
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Add event listener
|
|
22
|
-
window.addEventListener('resize', handleResize);
|
|
23
|
-
|
|
24
|
-
// Call handler right away so state gets updated with initial window size
|
|
25
|
-
handleResize();
|
|
26
|
-
|
|
27
|
-
// Remove event listener on cleanup
|
|
28
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
29
|
-
}, []); // Empty array ensures that effect is only run on mount
|
|
30
|
-
|
|
31
|
-
return windowSize;
|
|
32
|
-
}
|
|
33
|
-
// Como se usa
|
|
34
|
-
|
|
35
|
-
// 1 -const size = useWindowSize();
|
|
36
|
-
// 2 <div>
|
|
37
|
-
// {size.width}px / {size.height}px
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
export default function useWindowSize() {
|
|
4
|
+
// Initialize state with undefined width/height so server and client renders match
|
|
5
|
+
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
|
|
6
|
+
const [windowSize, setWindowSize] = useState({
|
|
7
|
+
width: undefined,
|
|
8
|
+
height: undefined
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
// Handler to call on window resize
|
|
13
|
+
function handleResize() {
|
|
14
|
+
// Set window width/height to state
|
|
15
|
+
setWindowSize({
|
|
16
|
+
width: window.innerWidth,
|
|
17
|
+
height: window.innerHeight
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Add event listener
|
|
22
|
+
window.addEventListener('resize', handleResize);
|
|
23
|
+
|
|
24
|
+
// Call handler right away so state gets updated with initial window size
|
|
25
|
+
handleResize();
|
|
26
|
+
|
|
27
|
+
// Remove event listener on cleanup
|
|
28
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
29
|
+
}, []); // Empty array ensures that effect is only run on mount
|
|
30
|
+
|
|
31
|
+
return windowSize;
|
|
32
|
+
}
|
|
33
|
+
// Como se usa
|
|
34
|
+
|
|
35
|
+
// 1 -const size = useWindowSize();
|
|
36
|
+
// 2 <div>
|
|
37
|
+
// {size.width}px / {size.height}px
|
|
38
38
|
// </div>
|
package/src/index.jsx
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './hooks/index'
|
|
1
|
+
export * from './hooks/index'
|
|
2
|
+
export * from './utils'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RandomCode } from '../../utils'
|
|
2
|
+
|
|
3
|
+
export const MockData = {
|
|
4
|
+
lists: {
|
|
5
|
+
'01list': {
|
|
6
|
+
id: RandomCode(9),
|
|
7
|
+
title: 'Elige tu salsa favorita',
|
|
8
|
+
numberLimit: 0,
|
|
9
|
+
required: 0,
|
|
10
|
+
value: '',
|
|
11
|
+
cards: [
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
listIds: ['01list']
|
|
16
|
+
}
|
package/src/utils/index.js
CHANGED
|
@@ -1,54 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description It takes an array of elements and returns an object with a submit hook for each element.
|
|
3
|
-
* @version 0.1.1
|
|
4
|
-
* @param {array} elements elementos del formulario
|
|
5
|
-
* @return {array} devuelve un array de booleanos con el nombre identificador para cada estado en react.
|
|
6
|
-
*/
|
|
7
|
-
export const validationSubmitHooks = elements => {
|
|
8
|
-
let errorForm = {}
|
|
9
|
-
for (const element of elements) {
|
|
10
|
-
if (element.name) {
|
|
11
|
-
if (element.type === 'text' || element.type === 'password' || element.type === 'email' || element.type === 'number' || element.type === 'hidden') {
|
|
12
|
-
if (element.dataset.required === 'true') {
|
|
13
|
-
if (!element.value) errorForm = { ...errorForm, [element.name]: !element.value }
|
|
14
|
-
else errorForm = { ...errorForm, [element.name]: !element.value }
|
|
15
|
-
} else {
|
|
16
|
-
errorForm = { ...errorForm, [element.name]: false }
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return errorForm
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const getCurrentDomain = () => {
|
|
25
|
-
return typeof window !== 'undefined' && window.location.hostname.split('.').slice(-2).join('.')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function RandomCode(length) {
|
|
29
|
-
let result = ''
|
|
30
|
-
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
31
|
-
let charactersLength = characters.length
|
|
32
|
-
for (let i = 0; i < length; i++) {
|
|
33
|
-
result += characters.charAt(Math.floor(Math.random() *
|
|
34
|
-
charactersLength))
|
|
35
|
-
}
|
|
36
|
-
return result
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* actualizar cache de apollo
|
|
40
|
-
* @param {{ cache: object, query: object, nameFun: string, dataNew: object, type: number, id: string }} params Parámetros para actualizar el cachet de apollo
|
|
41
|
-
* @returns {null} no hay retorno
|
|
42
|
-
*/
|
|
43
|
-
export const updateCacheMod = async ({ cache, query, nameFun, dataNew, type, id }) => {
|
|
44
|
-
return cache.modify({
|
|
45
|
-
fields: {
|
|
46
|
-
[nameFun](dataOld = []) {
|
|
47
|
-
if (type === 1) return cache.writeQuery({ query, data: [...(dataOld || []), { ...(dataNew || {}) }] })
|
|
48
|
-
if (type === 2) return cache.writeQuery({ query, data: { ...(dataOld || {}), ...(dataNew || {}) } })
|
|
49
|
-
if (type === 3) return cache.writeQuery({ query, data: dataOld.filter(x => { return x === id }) })
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
export const initializer = (initialValue = initialState) => { return JSON.parse(localStorage.getItem(process.env.LOCAL_SALES_STORE)) || initialValue }
|
|
1
|
+
/**
|
|
2
|
+
* @description It takes an array of elements and returns an object with a submit hook for each element.
|
|
3
|
+
* @version 0.1.1
|
|
4
|
+
* @param {array} elements elementos del formulario
|
|
5
|
+
* @return {array} devuelve un array de booleanos con el nombre identificador para cada estado en react.
|
|
6
|
+
*/
|
|
7
|
+
export const validationSubmitHooks = elements => {
|
|
8
|
+
let errorForm = {}
|
|
9
|
+
for (const element of elements) {
|
|
10
|
+
if (element.name) {
|
|
11
|
+
if (element.type === 'text' || element.type === 'password' || element.type === 'email' || element.type === 'number' || element.type === 'hidden') {
|
|
12
|
+
if (element.dataset.required === 'true') {
|
|
13
|
+
if (!element.value) errorForm = { ...errorForm, [element.name]: !element.value }
|
|
14
|
+
else errorForm = { ...errorForm, [element.name]: !element.value }
|
|
15
|
+
} else {
|
|
16
|
+
errorForm = { ...errorForm, [element.name]: false }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return errorForm
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const getCurrentDomain = () => {
|
|
25
|
+
return typeof window !== 'undefined' && window.location.hostname.split('.').slice(-2).join('.')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function RandomCode(length) {
|
|
29
|
+
let result = ''
|
|
30
|
+
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
31
|
+
let charactersLength = characters.length
|
|
32
|
+
for (let i = 0; i < length; i++) {
|
|
33
|
+
result += characters.charAt(Math.floor(Math.random() *
|
|
34
|
+
charactersLength))
|
|
35
|
+
}
|
|
36
|
+
return result
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* actualizar cache de apollo
|
|
40
|
+
* @param {{ cache: object, query: object, nameFun: string, dataNew: object, type: number, id: string }} params Parámetros para actualizar el cachet de apollo
|
|
41
|
+
* @returns {null} no hay retorno
|
|
42
|
+
*/
|
|
43
|
+
export const updateCacheMod = async ({ cache, query, nameFun, dataNew, type, id }) => {
|
|
44
|
+
return cache.modify({
|
|
45
|
+
fields: {
|
|
46
|
+
[nameFun](dataOld = []) {
|
|
47
|
+
if (type === 1) return cache.writeQuery({ query, data: [...(dataOld || []), { ...(dataNew || {}) }] })
|
|
48
|
+
if (type === 2) return cache.writeQuery({ query, data: { ...(dataOld || {}), ...(dataNew || {}) } })
|
|
49
|
+
if (type === 3) return cache.writeQuery({ query, data: dataOld.filter(x => { return x === id }) })
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
export const initializer = (initialValue = initialState) => { return JSON.parse(localStorage.getItem(process.env.LOCAL_SALES_STORE)) || initialValue }
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
export const numberFormat = value => { return value ? (parseInt(value) ? new Intl.NumberFormat('de-DE').format(parseFloat(`${value}`.replace(/\./g, ''))) : value) : (value) }
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export const MONTHS = [
|
|
62
|
+
'January',
|
|
63
|
+
'February',
|
|
64
|
+
'March',
|
|
65
|
+
'April',
|
|
66
|
+
'May',
|
|
67
|
+
'June',
|
|
68
|
+
'July',
|
|
69
|
+
'August',
|
|
70
|
+
'September',
|
|
71
|
+
'October',
|
|
72
|
+
'November',
|
|
73
|
+
'December'
|
|
74
|
+
]
|
|
75
|
+
export const SPANISH_MONTHS = {
|
|
76
|
+
0:'Enero',
|
|
77
|
+
1:'Febrero',
|
|
78
|
+
2:'Marzo',
|
|
79
|
+
3:'Abril',
|
|
80
|
+
4:'Mayo',
|
|
81
|
+
5:'Junio',
|
|
82
|
+
6:'Julio',
|
|
83
|
+
7:'Augosto',
|
|
84
|
+
8:'Septiembre',
|
|
85
|
+
9:'Octubre',
|
|
86
|
+
10:'Noviembre ',
|
|
87
|
+
11:'Diciembre'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export const convertBase64 = file => {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const reader = new FileReader()
|
|
94
|
+
if (file) {
|
|
95
|
+
reader.readAsDataURL(file)
|
|
96
|
+
}
|
|
97
|
+
reader.onload = () => {
|
|
98
|
+
resolve(reader.result)
|
|
99
|
+
}
|
|
100
|
+
reader.onerror = error => {
|
|
101
|
+
reject(error)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const validationImg = file => { return (/\.(jpg|png|gif|jpeg)$/i).test(file.name) }
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|