npm-pkg-hook 1.0.2 → 1.0.5

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 (85) hide show
  1. package/.babelrc +13 -13
  2. package/.env +1 -0
  3. package/.eslintrc.js +132 -0
  4. package/.eslintrc.json +107 -107
  5. package/.github/pull_request_template.md +17 -17
  6. package/.github/workflows/pepeline.yaml +29 -29
  7. package/.vscode/extensions.json +6 -0
  8. package/.vscode/settings.json +12 -0
  9. package/README.md +1 -1
  10. package/jsconfig.json +27 -27
  11. package/next.config.js +128 -128
  12. package/package.json +8 -6
  13. package/script.txt +7 -0
  14. package/src/cookies/index.ts +3 -3
  15. package/src/hooks/index.js +47 -19
  16. package/src/hooks/updateExtProductFoodsOptional/index.js +38 -0
  17. package/src/hooks/useAcumulateDate/index.js +16 -16
  18. package/src/hooks/useAnimationText/index.jsx +31 -30
  19. package/src/hooks/useBanner/index.js +19 -0
  20. package/src/hooks/useCatWithProduct/index.js +42 -0
  21. package/src/hooks/useCatWithProduct/queries.js +172 -0
  22. package/src/hooks/useCategoryInStore/index.js +94 -0
  23. package/src/hooks/{useGetCategorieStore → useCategoryInStore}/queries.js +77 -77
  24. package/src/hooks/useCategoryStore/index.js +7 -7
  25. package/src/hooks/useCategoryStore/queries.js +16 -16
  26. package/src/hooks/useChartData/index.js +170 -0
  27. package/src/hooks/useCheckbox/index.js +114 -114
  28. package/src/hooks/useClients/index.js +13 -13
  29. package/src/hooks/useClients/queries.js +117 -117
  30. package/src/hooks/useConnection/index.js +23 -0
  31. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +165 -0
  32. package/src/hooks/useCreateProduct/index.js +268 -0
  33. package/src/hooks/useDessert/index.js +141 -0
  34. package/src/hooks/useDrag/index.js +62 -57
  35. package/src/hooks/useEvent/index.js +33 -33
  36. package/src/hooks/useFetchJson/index.js +24 -24
  37. package/src/hooks/useFetchMoreInteractions/index.jsx +37 -34
  38. package/src/hooks/useFormTools/index.js +83 -70
  39. package/src/hooks/useFormatDate/index.js +34 -0
  40. package/src/hooks/useFullScreenMode/index.js +65 -65
  41. package/src/hooks/useHover/index.js +28 -28
  42. package/src/hooks/useImageOptimization/index.js +28 -0
  43. package/src/hooks/useImageWeight/index.js +52 -0
  44. package/src/hooks/useImagesStore/index.js +171 -0
  45. package/src/hooks/useImagesStore/queries.js +216 -0
  46. package/src/hooks/useInnerHtml/index.js +37 -37
  47. package/src/hooks/useIntersection/index.js +84 -31
  48. package/src/hooks/useKeypress/index.js +27 -27
  49. package/src/hooks/useLazyScript/index.js +72 -0
  50. package/src/hooks/useLocalSorage/index.js +35 -35
  51. package/src/hooks/useLocationNavigate/index.js +54 -54
  52. package/src/hooks/useMobile/index.js +37 -37
  53. package/src/hooks/useMutateHeight/index.js +37 -0
  54. package/src/hooks/useProductsFood/index.js +190 -0
  55. package/src/hooks/{useGetProductsFood → useProductsFood}/queriesStore.js +780 -765
  56. package/src/hooks/useProductsFood/usetagsProducts.js +57 -0
  57. package/src/hooks/useReactToPrint/index.js +1201 -0
  58. package/src/hooks/useReport/index.js +35 -0
  59. package/src/hooks/useReport/queries.js +122 -0
  60. package/src/hooks/useRestaurant/index.js +19 -19
  61. package/src/hooks/useRestaurant/queries.js +79 -69
  62. package/src/hooks/useSales/index.js +589 -489
  63. package/src/hooks/useSales/queries.js +290 -229
  64. package/src/hooks/useSales/useGetSale.js +12 -0
  65. package/src/hooks/useSales/useTotalSales.js +17 -0
  66. package/src/hooks/useSaveAvailableProduct/helpers/index.js +30 -0
  67. package/src/hooks/useSaveAvailableProduct/index.js +26 -0
  68. package/src/hooks/useSaveAvailableProduct/queries.js +10 -0
  69. package/src/hooks/useSchedule/index.jsx +23 -0
  70. package/src/hooks/useSetState/index.js +24 -24
  71. package/src/hooks/useStore/index.js +17 -17
  72. package/src/hooks/useStore/queries.js +135 -135
  73. package/src/hooks/useStoreCalendar/index.js +7 -0
  74. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  75. package/src/hooks/useUpdateCart/index.js +124 -124
  76. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +37 -0
  77. package/src/hooks/useUser/index.js +7 -3
  78. package/src/hooks/useUser/queries.js +69 -0
  79. package/src/hooks/useWindowSize/index.js +37 -37
  80. package/src/index.jsx +2 -1
  81. package/src/mock/dessert/index.js +16 -0
  82. package/src/mock/index.js +2 -0
  83. package/src/utils/index.js +106 -54
  84. package/src/hooks/useGetCategorieStore/index.js +0 -21
  85. package/src/hooks/useGetProductsFood/index.js +0 -46
package/next.config.js CHANGED
@@ -1,129 +1,129 @@
1
- /* eslint-disable consistent-return */
2
- /** @type {import('next').NextConfig} */
3
- const {
4
- PHASE_DEVELOPMENT_SERVER,
5
- PHASE_PRODUCTION_BUILD
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- } = require('next/constants')
8
- const nextConfig = {
9
- reactStrictMode: true
10
- }
11
- module.exports = (phase) => {
12
-
13
- // npm run dev or next dev
14
- const isDev = phase === PHASE_DEVELOPMENT_SERVER
15
- // npm run build or next build
16
- const isProd = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
17
- // npm run build or next build
18
- const isStaging = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
19
- const env = {
20
- NAMEDB: (() => {
21
- if (isDev) return 'app'
22
- if (isProd) return 'railway'
23
- })(),
24
- USERDB: (() => {
25
- if (isDev) return 'root'
26
- if (isProd) return 'root'
27
- })(),
28
- PASSDB: (() => {
29
- if (isDev) return ''
30
- if (isProd) return '8jpgm70bhVjWIxEFbsrt'
31
- })(),
32
- HOSTDB: (() => {
33
- if (isDev) return 'localhost'
34
- if (isProd) return 'containers-us-west-65.railway.app'
35
- })(),
36
- DIALECTDB: 'mysql',
37
- SESSION_NAME: 'vp.client',
38
- SESSION_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXa',
39
- URL_BASE: (() => {
40
- if (isDev) return 'http://localhost:3001/app/'
41
- if (isProd) return 'http://localhost:3001/app/'
42
- // if (isStaging) return 'Title Stg'
43
- })(),
44
- MAIN_URL_BASE: (() => {
45
- if (isDev) return 'http://localhost:3000/'
46
- if (isProd) return 'http://localhost:3000/'
47
- if (isStaging) return 'Title Stg'
48
- })(),
49
- // URL_BASE_WS
50
- URL_ADMIN_SERVER: (() => {
51
- if (isDev) return 'http://localhost:4000/'
52
- // if (isDev) return 'https://server-image-food.herokuapp.com/'
53
- if (isProd) return 'http://localhost:4000/'
54
- })(),
55
- // BANCOLOMBIA
56
- BANCOLOMBIA_CLIENT_KEY: '55929729-85fe-4ffe-928d-0bd317817be4',
57
- BANCOLOMBIA_SECRET_KEY: 'E1aM2bV2lD7vS8cH1qJ8oN0nD7eN0eP0rM8gU0cG2lL6uY5sO7',
58
- JWT_EXPIRY: 333300,
59
- REFRESH_TOKEN_EXPIRY: '604800',
60
- AUTHO_USER_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXV',
61
- ACCESS_SID_TWILIO: 'AC7c9ccbdb50400c504faf629e35aea8e4',
62
- REACT_APP_API_KEY_GOOGLE_MAPS: 'AIzaSyAy0SY1G3OFqesWSTQRHJvzyJzNgURPoN8',
63
- ACCESS_TOKEN_AUTH_TWILIO: '22e090d4d776ace7bb596ca77cba6b18'
64
- }
65
-
66
- const resolveUniqueReactForHooks = {
67
- webpack: (config, options) => {
68
- if (options.isServer) {
69
- config.externals = ['react', ...config.externals]
70
- }
71
- // eslint-disable-next-line no-undef
72
- config.resolve.alias.react = reactPath
73
- return config
74
- },
75
- images: {
76
- domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com']
77
- }
78
- }
79
- const headers = () => {
80
- return [
81
- {
82
- source: '/app',
83
- headers: [
84
- {
85
- key: 'x-custom-header-1',
86
- value: 'my custom header 1'
87
- }
88
- ]
89
- }
90
- ]
91
- }
92
- const redirects = () => {
93
- return [
94
- {
95
- source: '/home',
96
- destination: '/',
97
- permanent: true
98
- }
99
- ]
100
- }
101
- const basePath = '/app'
102
- // puedes sobre escribir la ruta
103
- const rewrites = () => {
104
- return [
105
- {
106
- source: '/ab',
107
- destination: '/about'
108
- }
109
- ]
110
- }
111
- const assetPrefix = isProd ? 'https://cdn.mydomain.com' : ''
112
- const images = {
113
- domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com', '*']
114
- }
115
- return {
116
- env,
117
- swcMinify: false,
118
- images,
119
- headers,
120
- optimizeFonts: false,
121
- nextConfig,
122
- // basePath,
123
- rewrites,
124
- redirects,
125
- assetPrefix,
126
- resolveUniqueReactForHooks
127
- }
128
- }
1
+ /* eslint-disable consistent-return */
2
+ /** @type {import('next').NextConfig} */
3
+ const {
4
+ PHASE_DEVELOPMENT_SERVER,
5
+ PHASE_PRODUCTION_BUILD
6
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
7
+ } = require('next/constants')
8
+ const nextConfig = {
9
+ reactStrictMode: true
10
+ }
11
+ module.exports = (phase) => {
12
+
13
+ // npm run dev or next dev
14
+ const isDev = phase === PHASE_DEVELOPMENT_SERVER
15
+ // npm run build or next build
16
+ const isProd = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
17
+ // npm run build or next build
18
+ const isStaging = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
19
+ const env = {
20
+ NAMEDB: (() => {
21
+ if (isDev) return 'app'
22
+ if (isProd) return 'railway'
23
+ })(),
24
+ USERDB: (() => {
25
+ if (isDev) return 'root'
26
+ if (isProd) return 'root'
27
+ })(),
28
+ PASSDB: (() => {
29
+ if (isDev) return ''
30
+ if (isProd) return '8jpgm70bhVjWIxEFbsrt'
31
+ })(),
32
+ HOSTDB: (() => {
33
+ if (isDev) return 'localhost'
34
+ if (isProd) return 'containers-us-west-65.railway.app'
35
+ })(),
36
+ DIALECTDB: 'mysql',
37
+ SESSION_NAME: 'vp.client',
38
+ SESSION_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXa',
39
+ URL_BASE: (() => {
40
+ if (isDev) return 'http://localhost:3001/'
41
+ if (isProd) return 'http://localhost:3001/'
42
+ // if (isStaging) return 'Title Stg'
43
+ })(),
44
+ MAIN_URL_BASE: (() => {
45
+ if (isDev) return 'http://localhost:3000/'
46
+ if (isProd) return 'http://localhost:3000/'
47
+ if (isStaging) return 'Title Stg'
48
+ })(),
49
+ // URL_BASE_WS
50
+ URL_ADMIN_SERVER: (() => {
51
+ if (isDev) return 'http://localhost:4000/'
52
+ // if (isDev) return 'https://server-image-food.herokuapp.com/'
53
+ if (isProd) return 'http://localhost:4000/'
54
+ })(),
55
+ // BANCOLOMBIA
56
+ BANCOLOMBIA_CLIENT_KEY: '55929729-85fe-4ffe-928d-0bd317817be4',
57
+ BANCOLOMBIA_SECRET_KEY: 'E1aM2bV2lD7vS8cH1qJ8oN0nD7eN0eP0rM8gU0cG2lL6uY5sO7',
58
+ JWT_EXPIRY: 333300,
59
+ REFRESH_TOKEN_EXPIRY: '604800',
60
+ AUTHO_USER_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXV',
61
+ ACCESS_SID_TWILIO: 'AC7c9ccbdb50400c504faf629e35aea8e4',
62
+ REACT_APP_API_KEY_GOOGLE_MAPS: 'AIzaSyAy0SY1G3OFqesWSTQRHJvzyJzNgURPoN8',
63
+ ACCESS_TOKEN_AUTH_TWILIO: '22e090d4d776ace7bb596ca77cba6b18'
64
+ }
65
+
66
+ const resolveUniqueReactForHooks = {
67
+ webpack: (config, options) => {
68
+ if (options.isServer) {
69
+ config.externals = ['react', ...config.externals]
70
+ }
71
+ // eslint-disable-next-line no-undef
72
+ config.resolve.alias.react = reactPath
73
+ return config
74
+ },
75
+ images: {
76
+ domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com']
77
+ }
78
+ }
79
+ const headers = () => {
80
+ return [
81
+ {
82
+ source: '',
83
+ headers: [
84
+ {
85
+ key: 'x-custom-header-1',
86
+ value: 'my custom header 1'
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ }
92
+ const redirects = () => {
93
+ return [
94
+ {
95
+ source: '/home',
96
+ destination: '/',
97
+ permanent: true
98
+ }
99
+ ]
100
+ }
101
+ const basePath = ''
102
+ // puedes sobre escribir la ruta
103
+ const rewrites = () => {
104
+ return [
105
+ {
106
+ source: '/ab',
107
+ destination: '/about'
108
+ }
109
+ ]
110
+ }
111
+ const assetPrefix = isProd ? 'https://cdn.mydomain.com' : ''
112
+ const images = {
113
+ domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com', '*']
114
+ }
115
+ return {
116
+ env,
117
+ swcMinify: false,
118
+ images,
119
+ headers,
120
+ optimizeFonts: false,
121
+ nextConfig,
122
+ // basePath,
123
+ rewrites,
124
+ redirects,
125
+ assetPrefix,
126
+ resolveUniqueReactForHooks
127
+ }
128
+ }
129
129
  // module.exports = nextConfig
package/package.json CHANGED
@@ -7,11 +7,12 @@
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/"
9
9
  },
10
- "version": "1.0.2",
10
+ "version": "1.0.5",
11
11
  "description": "description-pkg-hook",
12
12
  "main": "/src/index.jsx",
13
13
  "scripts": {
14
14
  "test": "echo \"Error: no test specified\" && exit 1",
15
+ "lint": "eslint .",
15
16
  "rm": "rm -rf node_modules package-lock.json && npm i"
16
17
  },
17
18
  "author": "",
@@ -20,6 +21,7 @@
20
21
  "@apollo/client": "3.6.9",
21
22
  "@typescript-eslint/parser": "^5.37.0",
22
23
  "js-cookie": "3.0.1",
24
+ "lodash": "^4.17.21",
23
25
  "moment": "^2.29.4",
24
26
  "react": "18.1.0",
25
27
  "react-dom": "18.1.0",
@@ -30,12 +32,12 @@
30
32
  "@babel/preset-react": "^7.18.6",
31
33
  "@babel/preset-typescript": "^7.18.6",
32
34
  "@types/react": "^18.0.20",
33
- "eslint": "^8.23.1",
35
+ "eslint": "^8.33.0",
34
36
  "eslint-config-standard": "^17.0.0",
35
- "eslint-plugin-import": "^2.26.0",
36
- "eslint-plugin-n": "^15.2.5",
37
- "eslint-plugin-promise": "^6.0.1",
38
- "eslint-plugin-react": "^7.31.8",
37
+ "eslint-plugin-import": "^2.27.5",
38
+ "eslint-plugin-n": "^15.6.1",
39
+ "eslint-plugin-promise": "^6.1.1",
40
+ "eslint-plugin-react": "^7.32.2",
39
41
  "eslint-plugin-react-hooks": "^4.6.0"
40
42
  }
41
43
  }
package/script.txt ADDED
@@ -0,0 +1,7 @@
1
+ // (function (params) {
2
+ // var ct = document.createElement('link');
3
+ // ct.rel = 'stylesheet';
4
+ // ct.href = 'https://csswizardry.com/ct/ct.css';
5
+ // ct.classList.add('ct');
6
+ // document.head.appendChild(ct)
7
+ // }());
@@ -1,3 +1,3 @@
1
- import Cookies from 'js-cookie'
2
-
3
- export { Cookies }
1
+ import Cookies from 'js-cookie'
2
+
3
+ export { Cookies }
@@ -1,19 +1,47 @@
1
- export * from './useCategoryStore'
2
- export * from './useCheckbox'
3
- export * from './useDrag'
4
- export * from './useEvent'
5
- export * from './useFetchJson'
6
- export * from './useFormTools/index'
7
- export * from './useGetCategorieStore'
8
- export * from './useHover'
9
- export * from './useKeypress'
10
- export * from './useLocalSorage'
11
- export * from './useLocationNavigate'
12
- export * from './useMobile'
13
- export * from './useRestaurant'
14
- export * from './useSales'
15
- export * from './useSetState'
16
- export * from './useTimeAgo/useTimeAgo'
17
- export * from './useUpdateCart'
18
- export * from './useUser'
19
- export * from './useClients'
1
+ export * from './updateExtProductFoodsOptional'
2
+ export * from './useAcumulateDate'
3
+ export * from './useBanner'
4
+ export * from './useCategoryInStore'
5
+ export * from './useCategoryStore'
6
+ export * from './useCatWithProduct'
7
+ export * from './useChartData'
8
+ export * from './useCheckbox'
9
+ export * from './useClients'
10
+ export * from './useConnection'
11
+ export * from './useCreateProduct'
12
+ export * from './useCreateProduct/helpers/useEditImageProduct'
13
+ export * from './useDessert'
14
+ export * from './useDrag'
15
+ export * from './useEvent'
16
+ export * from './useFetchJson'
17
+ export * from './useFormatDate'
18
+ export * from './useFormTools/index'
19
+ export * from './useHover'
20
+ export * from './useImageOptimization'
21
+ export * from './useImagesStore'
22
+ export * from './useImageWeight'
23
+ export * from './useIntersection'
24
+ export * from './useKeypress'
25
+ export * from './useLazyScript'
26
+ export * from './useLocalSorage'
27
+ export * from './useLocationNavigate'
28
+ export * from './useMobile'
29
+ export * from './useMutateHeight'
30
+ export * from './useProductsFood'
31
+ export * from './useProductsFood/usetagsProducts'
32
+ export * from './useReport'
33
+ export * from './useRestaurant'
34
+ export * from './useSales'
35
+ export * from './useSales/useGetSale'
36
+ export * from './useSales/useTotalSales'
37
+ export * from './useSaveAvailableProduct'
38
+ export * from './useSchedule'
39
+ export * from './useSetState'
40
+ export * from './useStore'
41
+ export * from './useStoreCalendar'
42
+ export * from './useTimeAgo/useTimeAgo'
43
+ export * from './useUpdateCart'
44
+ export * from './useUpdateExtProductFoodsSubOptional'
45
+ export * from './useUser'
46
+ export * from './useReactToPrint'
47
+
@@ -0,0 +1,38 @@
1
+ import { useMutation } from '@apollo/client'
2
+ import { updateCacheMod } from '../../utils'
3
+ import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useProductsFood/queriesStore'
4
+
5
+ export const useUpdateExtProductFoodsOptional = () => {
6
+ const [updateExtProductFoodsOptional] = useMutation(UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL)
7
+
8
+ const handleUpdateExtProduct = async ({
9
+ pId,
10
+ code,
11
+ OptionalProName,
12
+ required,
13
+ numbersOptionalOnly
14
+ }) => {
15
+ await updateExtProductFoodsOptional({
16
+ variables: {
17
+ input: {
18
+ pId,
19
+ code,
20
+ OptionalProName,
21
+ required,
22
+ numbersOptionalOnly
23
+ }
24
+ },
25
+ update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
26
+ return updateCacheMod({
27
+ cache,
28
+ query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
29
+ nameFun: 'ExtProductFoodsOptionalAll',
30
+ dataNew: ExtProductFoodsOptionalAll
31
+ })
32
+ }
33
+ })
34
+ }
35
+ return {
36
+ handleUpdateExtProduct
37
+ }
38
+ }
@@ -1,16 +1,16 @@
1
-
2
- const data = [
3
- { x: '2021-10-17T14:38:45.540Z', y: 2 }
4
- ]
5
- export const get_date_parts = (iso_string) => {
6
- const [year, month, day, hr, min, sec] = iso_string.split(/\D/g)
7
- return { year, month, day, hr, min, sec }
8
- }
9
- function group_by_year(arr) {
10
- let total = arr.reduce((a, b) => {
11
- const { day } = get_date_parts(b.x)
12
- return a + parseInt(day)
13
- }, 0)
14
- return total
15
- }
16
- const result = group_by_year(data)
1
+
2
+ const data = [
3
+ { x: '2021-10-17T14:38:45.540Z', y: 2 }
4
+ ]
5
+ export const getDateParts = (isString) => {
6
+ const [year, month, day, hr, min, sec] = isString.split(/\D/g)
7
+ return { year, month, day, hr, min, sec }
8
+ }
9
+ export function groupDates (arr) {
10
+ const total = arr.reduce((a, b) => {
11
+ const { hr } = getDateParts(b.x)
12
+ return a + parseInt(hr)
13
+ }, 0)
14
+ return total
15
+ }
16
+ const result = groupDates(data)
@@ -1,30 +1,31 @@
1
- import React, { useEffect, useState, useRef } from 'react'
2
-
3
- const fullText =
4
- ' this is full text it\'ll be animated again! Writing a really huge senetence here so that I can see the animation happen. I know it\'s fast but that\'s how it goes.'
5
-
6
- const useAnimatedText = textMessage => {
7
- const fullTextRef = useRef(textMessage)
8
- const [text, setText] = useState('')
9
- const [index, setIndex] = useState(0)
10
- useEffect(() => {
11
- if (index < fullText.length) {
12
- window.requestAnimationFrame(() => {
13
- // eslint-disable-next-line
14
- setText(text => text + fullTextRef.current[index]);
15
- setIndex(() => {return index + 1})
16
- })
17
- }
18
- }, [index])
19
- useEffect(() => {
20
- fullText.current = textMessage
21
- }, [textMessage])
22
-
23
- return text
24
- }
25
-
26
- export default function TextHook() {
27
- const text = useAnimatedText(fullText)
28
-
29
- return <span>{text} </span>
30
- }
1
+ import { useEffect, useRef, useState } from 'react'
2
+
3
+ const fullText =
4
+ ' this is full text it\'ll be animated again! Writing a really huge senetence here so that I can see the animation happen. I know it\'s fast but that\'s how it goes.'
5
+
6
+ export const useAnimatedText = textMessage => {
7
+ const fullTextRef = useRef(textMessage)
8
+ const [text, setText] = useState('')
9
+ const [index, setIndex] = useState(0)
10
+
11
+ useEffect(() => {
12
+ if (index < fullText.length) {
13
+ window.requestAnimationFrame(() => {
14
+ // eslint-disable-next-line
15
+ setText(text => text + fullTextRef.current[index]);
16
+ setIndex(() => {return index + 1})
17
+ })
18
+ }
19
+ }, [index])
20
+ useEffect(() => {
21
+ fullText.current = textMessage
22
+ }, [textMessage])
23
+
24
+ return text
25
+ }
26
+
27
+ // export default function TextHook() {
28
+ // const text = useAnimatedText(fullText)
29
+
30
+ // return <span>{text} </span>
31
+ // }
@@ -0,0 +1,19 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { GET_ONE_BANNER_STORE } from '../useProductsFood/queriesStore'
3
+ import { useStore } from '../useStore'
4
+
5
+ export const useBanner = () => {
6
+ const [store, { loading: loaStore }] = useStore()
7
+
8
+ const {
9
+ data,
10
+ loading,
11
+ error
12
+ } = useQuery(GET_ONE_BANNER_STORE, {
13
+ context: { clientName: 'admin-server' },
14
+ variables: {
15
+ idStore: !loaStore && store?.store
16
+ }
17
+ })
18
+ return [data?.getOneBanners, { loading, error }]
19
+ }
@@ -0,0 +1,42 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { GET_ALL_CATEGORIES_WITH_PRODUCT } from './queries'
3
+
4
+ export const useCatWithProduct = ({
5
+ max = 1,
6
+ min = 0,
7
+ search = null,
8
+ searchFilter= {}
9
+ }) => {
10
+ const {
11
+ gender,
12
+ desc,
13
+ speciality
14
+ } = searchFilter || {}
15
+ const {
16
+ data,
17
+ loading,
18
+ error,
19
+ fetchMore
20
+ } = useQuery(GET_ALL_CATEGORIES_WITH_PRODUCT, {
21
+ fetchPolicy: 'network-only',
22
+ variables:
23
+ {
24
+ search,
25
+ gender: gender,
26
+ min,
27
+ max: 400,
28
+ desc: desc,
29
+ categories: speciality
30
+ }
31
+ })
32
+ const totalCount = data?.getCatProductsWithProduct?.totalCount
33
+ return [
34
+ data?.getCatProductsWithProduct?.catProductsWithProduct,
35
+ {
36
+ loading,
37
+ error,
38
+ fetchMore,
39
+ totalCount
40
+ }
41
+ ]
42
+ }