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.
Files changed (65) hide show
  1. package/.env +1 -0
  2. package/.eslintrc.js +132 -0
  3. package/.github/pull_request_template.md +18 -0
  4. package/.github/workflows/pepeline.yaml +30 -0
  5. package/.vscode/extensions.json +6 -0
  6. package/.vscode/settings.json +12 -0
  7. package/next.config.js +4 -4
  8. package/package.json +17 -7
  9. package/script.txt +7 -0
  10. package/src/hooks/index.js +39 -8
  11. package/src/hooks/updateExtProductFoodsOptional/index.js +38 -0
  12. package/src/hooks/useAcumulateDate/index.js +14 -14
  13. package/src/hooks/useAnimationText/index.jsx +7 -6
  14. package/src/hooks/useBanner/index.js +19 -0
  15. package/src/hooks/useCatWithProduct/index.js +42 -0
  16. package/src/hooks/useCatWithProduct/queries.js +172 -0
  17. package/src/hooks/useCategoryInStore/index.js +94 -0
  18. package/src/hooks/{useGetCategorieStore → useCategoryInStore}/queries.js +0 -0
  19. package/src/hooks/useChartData/index.js +168 -0
  20. package/src/hooks/useCheckbox/index.js +114 -0
  21. package/src/hooks/useClients/index.js +13 -0
  22. package/src/hooks/useClients/queries.js +118 -0
  23. package/src/hooks/useConnection/index.js +23 -0
  24. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +165 -0
  25. package/src/hooks/useCreateProduct/index.js +268 -0
  26. package/src/hooks/useDessert/index.js +141 -0
  27. package/src/hooks/useDrag/index.js +14 -9
  28. package/src/hooks/useFetchMoreInteractions/index.jsx +6 -3
  29. package/src/hooks/useFormTools/index.js +16 -3
  30. package/src/hooks/useFormatDate/index.js +34 -0
  31. package/src/hooks/useImageOptimization/index.js +28 -0
  32. package/src/hooks/useImageWeight/index.js +52 -0
  33. package/src/hooks/useImagesStore/index.js +171 -0
  34. package/src/hooks/useImagesStore/queries.js +216 -0
  35. package/src/hooks/useIntersection/index.js +54 -1
  36. package/src/hooks/useLazyScript/index.js +72 -0
  37. package/src/hooks/useLocationNavigate/index.js +1 -1
  38. package/src/hooks/useMobile/index.js +38 -0
  39. package/src/hooks/useMutateHeight/index.js +37 -0
  40. package/src/hooks/useProductsFood/index.js +190 -0
  41. package/src/hooks/useProductsFood/queriesStore.js +781 -0
  42. package/src/hooks/useProductsFood/usetagsProducts.js +57 -0
  43. package/src/hooks/useReport/index.js +35 -0
  44. package/src/hooks/useReport/queries.js +122 -0
  45. package/src/hooks/useRestaurant/queries.js +11 -1
  46. package/src/hooks/useSales/index.js +589 -0
  47. package/src/hooks/useSales/queries.js +291 -0
  48. package/src/hooks/useSales/useGetSale.js +12 -0
  49. package/src/hooks/useSales/useTotalSales.js +17 -0
  50. package/src/hooks/useSaveAvailableProduct/helpers/index.js +30 -0
  51. package/src/hooks/useSaveAvailableProduct/index.js +26 -0
  52. package/src/hooks/useSaveAvailableProduct/queries.js +10 -0
  53. package/src/hooks/useSchedule/index.jsx +23 -0
  54. package/src/hooks/useStore/index.js +18 -0
  55. package/src/hooks/useStore/queries.js +136 -0
  56. package/src/hooks/useStoreCalendar/index.js +7 -0
  57. package/src/hooks/useUpdateCart/index.js +5 -4
  58. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +37 -0
  59. package/src/hooks/useUser/index.js +6 -2
  60. package/src/hooks/useUser/queries.js +69 -0
  61. package/src/index.jsx +2 -1
  62. package/src/mock/dessert/index.js +16 -0
  63. package/src/mock/index.js +2 -0
  64. package/src/utils/index.js +80 -1
  65. package/src/hooks/useGetCategorieStore/index.js +0 -21
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './dessert';
2
+
@@ -24,4 +24,83 @@ export const validationSubmitHooks = elements => {
24
24
  export const getCurrentDomain = () => {
25
25
  return typeof window !== 'undefined' && window.location.hostname.split('.').slice(-2).join('.')
26
26
  }
27
-
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
- }