npm-pkg-hook 1.0.1 → 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/.env +1 -0
- package/.eslintrc.js +132 -0
- package/.github/pull_request_template.md +18 -0
- package/.github/workflows/pepeline.yaml +30 -0
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +12 -0
- package/next.config.js +4 -4
- package/package.json +17 -7
- package/script.txt +7 -0
- package/src/hooks/index.js +39 -8
- package/src/hooks/updateExtProductFoodsOptional/index.js +38 -0
- package/src/hooks/useAcumulateDate/index.js +14 -14
- package/src/hooks/useAnimationText/index.jsx +7 -6
- 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 +0 -0
- package/src/hooks/useChartData/index.js +168 -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/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 +14 -9
- package/src/hooks/useFetchMoreInteractions/index.jsx +6 -3
- package/src/hooks/useFormTools/index.js +16 -3
- package/src/hooks/useFormatDate/index.js +34 -0
- 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/useIntersection/index.js +54 -1
- package/src/hooks/useLazyScript/index.js +72 -0
- package/src/hooks/useLocationNavigate/index.js +1 -1
- package/src/hooks/useMobile/index.js +38 -0
- package/src/hooks/useMutateHeight/index.js +37 -0
- package/src/hooks/useProductsFood/index.js +190 -0
- package/src/hooks/useProductsFood/queriesStore.js +781 -0
- 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/queries.js +11 -1
- package/src/hooks/useSales/index.js +589 -0
- package/src/hooks/useSales/queries.js +291 -0
- 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/useStore/index.js +18 -0
- package/src/hooks/useStore/queries.js +136 -0
- package/src/hooks/useStoreCalendar/index.js +7 -0
- package/src/hooks/useUpdateCart/index.js +5 -4
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +37 -0
- package/src/hooks/useUser/index.js +6 -2
- package/src/hooks/useUser/queries.js +69 -0
- 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 +80 -1
- package/src/hooks/useGetCategorieStore/index.js +0 -21
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useLazyQuery,
|
|
3
|
+
useMutation,
|
|
4
|
+
useQuery
|
|
5
|
+
} from '@apollo/client'
|
|
6
|
+
import { useEffect, useState } from 'react'
|
|
7
|
+
import {
|
|
8
|
+
GET_ALL_EXTRA_PRODUCT,
|
|
9
|
+
GET_ALL_PRODUCT_STORE,
|
|
10
|
+
GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
11
|
+
GET_ONE_PRODUCTS_FOOD,
|
|
12
|
+
UPDATE_PRODUCT_FOOD
|
|
13
|
+
} from './queriesStore'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Description
|
|
17
|
+
* @param {any} categories
|
|
18
|
+
* @param {any} desc
|
|
19
|
+
* @param {any} fetchPolicy='network-only'
|
|
20
|
+
* @param {any} fromDate
|
|
21
|
+
* @param {any} gender
|
|
22
|
+
* @param {any} max=50
|
|
23
|
+
* @param {any} min
|
|
24
|
+
* @param {any} pState
|
|
25
|
+
* @param {any} search=null
|
|
26
|
+
* @param {any} toDate
|
|
27
|
+
* @returns {any}
|
|
28
|
+
*/
|
|
29
|
+
export const useProductsFood = ({
|
|
30
|
+
categories,
|
|
31
|
+
desc,
|
|
32
|
+
fetchPolicy = 'network-only',
|
|
33
|
+
fromDate,
|
|
34
|
+
gender,
|
|
35
|
+
max = 50,
|
|
36
|
+
min,
|
|
37
|
+
pState,
|
|
38
|
+
search = null,
|
|
39
|
+
toDate
|
|
40
|
+
}) => {
|
|
41
|
+
const [productsFood, setProductsFood] = useState([])
|
|
42
|
+
const [showMore, setShowMore] = useState(50)
|
|
43
|
+
const { data, loading, fetchMore, error } = useQuery(GET_ALL_PRODUCT_STORE, {
|
|
44
|
+
fetchPolicy: fetchPolicy,
|
|
45
|
+
variables:
|
|
46
|
+
{
|
|
47
|
+
categories: categories || [],
|
|
48
|
+
desc: desc || [],
|
|
49
|
+
fromDate: fromDate || null,
|
|
50
|
+
gender: gender || [],
|
|
51
|
+
max: max || null,
|
|
52
|
+
min: min || null,
|
|
53
|
+
pState: pState || 0,
|
|
54
|
+
search: search ?? search,
|
|
55
|
+
toDate: toDate || null
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setProductsFood(data?.productFoodsAll || [])
|
|
60
|
+
}, [data, productsFood])
|
|
61
|
+
return [
|
|
62
|
+
productsFood, {
|
|
63
|
+
error,
|
|
64
|
+
loading,
|
|
65
|
+
showMore,
|
|
66
|
+
fetchMore,
|
|
67
|
+
setShowMore
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const useDeleteProductsFood = () => {
|
|
73
|
+
const [updateProductFoods] = useMutation(UPDATE_PRODUCT_FOOD)
|
|
74
|
+
|
|
75
|
+
const handleDelete = product => {
|
|
76
|
+
const { pId, pState } = product || {}
|
|
77
|
+
updateProductFoods({
|
|
78
|
+
variables: {
|
|
79
|
+
input: {
|
|
80
|
+
pId,
|
|
81
|
+
pState
|
|
82
|
+
}
|
|
83
|
+
}, update(cache) {
|
|
84
|
+
cache.modify({
|
|
85
|
+
fields: {
|
|
86
|
+
productFoodsAll(dataOld = []) {
|
|
87
|
+
return cache.writeQuery({ query: GET_ALL_PRODUCT_STORE, data: dataOld })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
cache.modify({
|
|
92
|
+
fields: {
|
|
93
|
+
getCatProductsWithProduct(dataOld = []) {
|
|
94
|
+
return cache.writeQuery({ query: GET_ALL_CATEGORIES_WITH_PRODUCT, data: dataOld })
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}).catch(err => { return console.log({ message: `${err}`, duration: 7000 }) })
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
handleDelete
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
export const useExtProductFoodsAll = () => {
|
|
108
|
+
const [ExtProductFoodsAll,
|
|
109
|
+
{
|
|
110
|
+
data,
|
|
111
|
+
loading,
|
|
112
|
+
error
|
|
113
|
+
}
|
|
114
|
+
] = useLazyQuery(GET_ALL_EXTRA_PRODUCT)
|
|
115
|
+
|
|
116
|
+
const handleExtProductFoodsAll = (pId) => {
|
|
117
|
+
ExtProductFoodsAll({
|
|
118
|
+
variables: {
|
|
119
|
+
pId
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
return [handleExtProductFoodsAll,
|
|
124
|
+
{
|
|
125
|
+
data: data?.ExtProductFoodsAll || [],
|
|
126
|
+
loading,
|
|
127
|
+
error
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
export const useExtProductFoodsOptionalAll = () => {
|
|
132
|
+
|
|
133
|
+
const [ExtProductFoodsOptionalAll,
|
|
134
|
+
{
|
|
135
|
+
data,
|
|
136
|
+
loading,
|
|
137
|
+
error
|
|
138
|
+
}] = useLazyQuery(GET_EXTRAS_PRODUCT_FOOD_OPTIONAL)
|
|
139
|
+
|
|
140
|
+
const handleGetExtProductFood = (pId) => {
|
|
141
|
+
try {
|
|
142
|
+
ExtProductFoodsOptionalAll({
|
|
143
|
+
variables: {
|
|
144
|
+
pId
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.log(e)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [handleGetExtProductFood,
|
|
152
|
+
{
|
|
153
|
+
data: data?.ExtProductFoodsOptionalAll || [],
|
|
154
|
+
loading,
|
|
155
|
+
error,
|
|
156
|
+
}]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
export const useGetOneProductsFood = () => {
|
|
161
|
+
const [productFoodsOne,
|
|
162
|
+
{
|
|
163
|
+
data,
|
|
164
|
+
loading,
|
|
165
|
+
error
|
|
166
|
+
}] = useLazyQuery(GET_ONE_PRODUCTS_FOOD)
|
|
167
|
+
const [handleGetExtProductFood, { data: dataOptional }] = useExtProductFoodsOptionalAll()
|
|
168
|
+
const [handleExtProductFoodsAll, { data: dataExtra }] = useExtProductFoodsAll()
|
|
169
|
+
const handleGetOneProduct = (food) => {
|
|
170
|
+
const { pId } = food
|
|
171
|
+
try {
|
|
172
|
+
productFoodsOne({
|
|
173
|
+
variables: {
|
|
174
|
+
pId: pId
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
handleGetExtProductFood(pId)
|
|
178
|
+
handleExtProductFoodsAll(pId)
|
|
179
|
+
} catch (e) {
|
|
180
|
+
console.log(e)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return [handleGetOneProduct, {
|
|
184
|
+
data: data?.productFoodsOne || {},
|
|
185
|
+
dataExtra,
|
|
186
|
+
dataOptional,
|
|
187
|
+
loading,
|
|
188
|
+
error,
|
|
189
|
+
}]
|
|
190
|
+
}
|