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
package/src/utils/index.js
CHANGED
|
@@ -1,27 +1,54 @@
|
|
|
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
|
-
|
|
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 }
|