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.
Files changed (46) hide show
  1. package/.babelrc +13 -13
  2. package/.eslintrc.json +107 -107
  3. package/.github/pull_request_template.md +18 -0
  4. package/.github/workflows/pepeline.yaml +30 -0
  5. package/README.md +1 -1
  6. package/jsconfig.json +27 -27
  7. package/next.config.js +128 -128
  8. package/package.json +10 -2
  9. package/src/cookies/index.ts +3 -3
  10. package/src/hooks/index.js +19 -15
  11. package/src/hooks/useAcumulateDate/index.js +15 -15
  12. package/src/hooks/useAnimationText/index.jsx +29 -29
  13. package/src/hooks/useCategoryStore/index.js +7 -7
  14. package/src/hooks/useCategoryStore/queries.js +16 -16
  15. package/src/hooks/useCheckbox/index.js +114 -0
  16. package/src/hooks/useClients/index.js +13 -0
  17. package/src/hooks/useClients/queries.js +118 -0
  18. package/src/hooks/useDrag/index.js +56 -56
  19. package/src/hooks/useEvent/index.js +33 -33
  20. package/src/hooks/useFetchJson/index.js +24 -24
  21. package/src/hooks/useFetchMoreInteractions/index.jsx +34 -34
  22. package/src/hooks/useFormTools/index.js +70 -70
  23. package/src/hooks/useFullScreenMode/index.js +65 -65
  24. package/src/hooks/useGetCategorieStore/index.js +20 -20
  25. package/src/hooks/useGetCategorieStore/queries.js +77 -77
  26. package/src/hooks/useGetProductsFood/index.js +46 -0
  27. package/src/hooks/useGetProductsFood/queriesStore.js +766 -0
  28. package/src/hooks/useHover/index.js +28 -28
  29. package/src/hooks/useInnerHtml/index.js +37 -37
  30. package/src/hooks/useIntersection/index.js +30 -30
  31. package/src/hooks/useKeypress/index.js +27 -27
  32. package/src/hooks/useLocalSorage/index.js +35 -35
  33. package/src/hooks/useLocationNavigate/index.js +54 -54
  34. package/src/hooks/useMobile/index.js +38 -0
  35. package/src/hooks/useRestaurant/index.js +19 -19
  36. package/src/hooks/useRestaurant/queries.js +69 -69
  37. package/src/hooks/useSales/index.js +489 -0
  38. package/src/hooks/useSales/queries.js +230 -0
  39. package/src/hooks/useSetState/index.js +24 -24
  40. package/src/hooks/useStore/index.js +18 -0
  41. package/src/hooks/useStore/queries.js +136 -0
  42. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  43. package/src/hooks/useUpdateCart/index.js +124 -123
  44. package/src/hooks/useUser/index.js +3 -3
  45. package/src/hooks/useWindowSize/index.js +37 -37
  46. package/src/utils/index.js +54 -27
@@ -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 }