npm-pkg-hook 1.1.2 → 1.1.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 (42) hide show
  1. package/.eslintrc.js +132 -132
  2. package/.vscode/extensions.json +6 -0
  3. package/.vscode/settings.json +8 -0
  4. package/next.config.js +1 -0
  5. package/package.json +43 -46
  6. package/src/config/client/errors.js +1 -2
  7. package/src/hooks/index.js +20 -25
  8. package/src/hooks/useAnimationText/index.jsx +13 -11
  9. package/src/hooks/useCatWithProduct/index.js +4 -37
  10. package/src/hooks/useCatWithProduct/queries.js +16 -0
  11. package/src/hooks/useChartData/index.js +156 -182
  12. package/src/hooks/useChartData/useChartData/index.js +197 -0
  13. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -0
  14. package/src/hooks/useCheckbox/index.js +2 -5
  15. package/src/hooks/useClients/index.js +8 -17
  16. package/src/hooks/useCreateProduct/index.js +64 -94
  17. package/src/hooks/useDrag/index.js +1 -0
  18. package/src/hooks/useEmployee/index.js +8 -11
  19. package/src/hooks/useFormTools/index.js +1 -1
  20. package/src/hooks/useFullScreenMode/index.js +8 -8
  21. package/src/hooks/useGoogleLogin/index.js +161 -0
  22. package/src/hooks/useGoogleLogin/loadScript.js +15 -0
  23. package/src/hooks/useGoogleLogin/removeScript.js +7 -0
  24. package/src/hooks/useHover/index.js +1 -1
  25. package/src/hooks/useImagesStore/index.js +144 -176
  26. package/src/hooks/useImagesStore/queries.js +28 -1
  27. package/src/hooks/useKeypress/index.js +1 -7
  28. package/src/hooks/useLogout/index.js +27 -22
  29. package/src/hooks/useManageQueryParams/index.js +1 -1
  30. package/src/hooks/useProductsFood/queriesStore.js +16 -3
  31. package/src/hooks/useReport/index.js +30 -26
  32. package/src/hooks/useReport/queries.js +32 -47
  33. package/src/hooks/useSales/index.js +21 -52
  34. package/src/hooks/useSales/queries.js +38 -48
  35. package/src/hooks/useSales/useGetSale.js +2 -16
  36. package/src/hooks/useSchedule/index.jsx +23 -0
  37. package/src/hooks/useUpdateExistingOrders/index.js +8 -8
  38. package/src/hooks/useUser/index.js +2 -2
  39. package/src/hooks/useUser/queries.js +40 -40
  40. package/src/hooks/useWindowSize/index.js +1 -1
  41. package/src/index.jsx +1 -2
  42. package/src/security/index.js +0 -0
package/.eslintrc.js CHANGED
@@ -1,132 +1,132 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es2021: true,
5
- node: true
6
- },
7
- extends: [
8
- 'plugin:react/recommended',
9
- 'standard'
10
- ],
11
- overrides: [
12
- ],
13
- parserOptions: {
14
- ecmaVersion: 'latest',
15
- sourceType: 'module'
16
- },
17
- plugins: [
18
- 'react',
19
- 'react-hooks',
20
- '@typescript-eslint'
21
- ],
22
- rules: {
23
- 'import/no-anonymous-default-export': ['error', {
24
- allowArray: false,
25
- allowArrowFunction: false,
26
- allowAnonymousClass: false,
27
- allowAnonymousFunction: false,
28
- allowCallExpression: true, // The true value here is for backward compatibility
29
- allowLiteral: false,
30
- allowObject: true // anonymous-default-export
31
- }],
32
- // react hooks validations
33
- 'react-hooks/exhaustive-deps': 'warn',
34
- 'react-hooks/rules-of-hooks': 'error',
35
- // allow jsx syntax in js files (for next.js project)
36
- 'react/jsx-filename-extension': [
37
- 1,
38
- {
39
- extensions: [
40
- '.js',
41
- '.jsx',
42
- '.ts',
43
- '.tsx'
44
- ]
45
- }
46
- ],
47
- quotes: [
48
- 2,
49
- 'single',
50
- {
51
- avoidEscape: true,
52
- allowTemplateLiterals: true
53
- }
54
- ],
55
- 'consistent-return': 2,
56
- indent: [
57
- 2,
58
- 2,
59
- {
60
- SwitchCase: 1
61
- }
62
- ],
63
- 'no-else-return': 1,
64
- semi: [
65
- 1,
66
- 'never'
67
- ],
68
- 'space-unary-ops': 2,
69
- 'comma-dangle': [
70
- 'error',
71
- {
72
- arrays: 'never',
73
- objects: 'never',
74
- imports: 'never',
75
- exports: 'never',
76
- functions: 'never'
77
- }
78
- ],
79
- 'one-var': [
80
- 2,
81
- 'never'
82
- ],
83
- 'no-var': 'error',
84
- 'arrow-body-style': [
85
- 'error',
86
- 'always'
87
- ],
88
- 'no-console': 'error',
89
- 'no-multi-spaces': [
90
- 'error',
91
- {
92
- exceptions: {
93
- BinaryExpression: true
94
- }
95
- }
96
- ],
97
- 'no-multiple-empty-lines': [
98
- 'error',
99
- {
100
- max: 2,
101
- maxBOF: 2
102
- }
103
- ],
104
- 'jsx-quotes': [
105
- 'error',
106
- 'prefer-single'
107
- ],
108
- 'react/jsx-sort-props': [
109
- 'error',
110
- {
111
- noSortAlphabetically: false
112
- }
113
- ],
114
- 'react/jsx-first-prop-new-line': [
115
- 'error',
116
- 'multiline'
117
- ],
118
- 'react/jsx-max-props-per-line': [
119
- 'error',
120
- {
121
- maximum: {
122
- single: 2,
123
- multi: 1
124
- }
125
- }
126
- ],
127
- 'react/jsx-closing-bracket-location': [
128
- 'error',
129
- 'line-aligned'
130
- ]
131
- }
132
- }
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ node: true
6
+ },
7
+ extends: [
8
+ 'plugin:react/recommended',
9
+ 'standard'
10
+ ],
11
+ overrides: [
12
+ ],
13
+ parserOptions: {
14
+ ecmaVersion: 'latest',
15
+ sourceType: 'module'
16
+ },
17
+ plugins: [
18
+ 'react',
19
+ 'react-hooks',
20
+ '@typescript-eslint'
21
+ ],
22
+ rules: {
23
+ 'import/no-anonymous-default-export': ['error', {
24
+ allowArray: false,
25
+ allowArrowFunction: false,
26
+ allowAnonymousClass: false,
27
+ allowAnonymousFunction: false,
28
+ allowCallExpression: true, // The true value here is for backward compatibility
29
+ allowLiteral: false,
30
+ allowObject: true // anonymous-default-export
31
+ }],
32
+ // react hooks validations
33
+ 'react-hooks/exhaustive-deps': 'warn',
34
+ 'react-hooks/rules-of-hooks': 'error',
35
+ // allow jsx syntax in js files (for next.js project)
36
+ 'react/jsx-filename-extension': [
37
+ 1,
38
+ {
39
+ extensions: [
40
+ '.js',
41
+ '.jsx',
42
+ '.ts',
43
+ '.tsx'
44
+ ]
45
+ }
46
+ ],
47
+ quotes: [
48
+ 2,
49
+ 'single',
50
+ {
51
+ avoidEscape: true,
52
+ allowTemplateLiterals: true
53
+ }
54
+ ],
55
+ 'consistent-return': 2,
56
+ indent: [
57
+ 2,
58
+ 2,
59
+ {
60
+ SwitchCase: 1
61
+ }
62
+ ],
63
+ 'no-else-return': 1,
64
+ semi: [
65
+ 1,
66
+ 'never'
67
+ ],
68
+ 'space-unary-ops': 2,
69
+ 'comma-dangle': [
70
+ 'error',
71
+ {
72
+ arrays: 'never',
73
+ objects: 'never',
74
+ imports: 'never',
75
+ exports: 'never',
76
+ functions: 'never'
77
+ }
78
+ ],
79
+ 'one-var': [
80
+ 2,
81
+ 'never'
82
+ ],
83
+ 'no-var': 'error',
84
+ 'arrow-body-style': [
85
+ 'error',
86
+ 'always'
87
+ ],
88
+ 'no-console': 'error',
89
+ 'no-multi-spaces': [
90
+ 'error',
91
+ {
92
+ exceptions: {
93
+ BinaryExpression: true
94
+ }
95
+ }
96
+ ],
97
+ 'no-multiple-empty-lines': [
98
+ 'error',
99
+ {
100
+ max: 2,
101
+ maxBOF: 2
102
+ }
103
+ ],
104
+ 'jsx-quotes': [
105
+ 'error',
106
+ 'prefer-single'
107
+ ],
108
+ 'react/jsx-sort-props': [
109
+ 'error',
110
+ {
111
+ noSortAlphabetically: false
112
+ }
113
+ ],
114
+ 'react/jsx-first-prop-new-line': [
115
+ 'error',
116
+ 'multiline'
117
+ ],
118
+ 'react/jsx-max-props-per-line': [
119
+ 'error',
120
+ {
121
+ maximum: {
122
+ single: 2,
123
+ multi: 1
124
+ }
125
+ }
126
+ ],
127
+ 'react/jsx-closing-bracket-location': [
128
+ 'error',
129
+ 'line-aligned'
130
+ ]
131
+ }
132
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "recommendations": [
3
+ "github.copilot",
4
+ "github.copilot-nightly"
5
+ ]
6
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "cSpell.words": [
3
+ "Anauthorized",
4
+ "deepmerge",
5
+ "Eliminado",
6
+ "Pedido"
7
+ ]
8
+ }
package/next.config.js CHANGED
@@ -46,6 +46,7 @@ module.exports = (phase) => {
46
46
  if (isProd) return 'http://localhost:3000/'
47
47
  if (isStaging) return 'Title Stg'
48
48
  })(),
49
+ // URL_BASE_WS
49
50
  URL_ADMIN_SERVER: (() => {
50
51
  if (isDev) return 'http://localhost:4000/'
51
52
  // if (isDev) return 'https://server-image-food.herokuapp.com/'
package/package.json CHANGED
@@ -1,46 +1,43 @@
1
- {
2
- "name": "npm-pkg-hook",
3
- "repository": {
4
- "type": "git",
5
- "url": "https://github.com/Jesus123780/pkg-hook"
6
- },
7
- "publishConfig": {
8
- "registry": "https://registry.npmjs.org/"
9
- },
10
- "version": "1.1.2",
11
- "description": "description-pkg-hook",
12
- "main": "/src/index.jsx",
13
- "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1",
15
- "lint": "eslint .",
16
- "rm": "rm -rf node_modules package-lock.json && npm i"
17
- },
18
- "author": "",
19
- "license": "ISC",
20
- "dependencies": {
21
- "@apollo/client": "3.6.9",
22
- "@typescript-eslint/parser": "^5.37.0",
23
- "crypto-js": "4.1.1",
24
- "js-cookie": "3.0.1",
25
- "lodash": "4.17.21",
26
- "md5": "2.3.0",
27
- "moment": "^2.29.4",
28
- "react": "18.1.0",
29
- "react-dom": "18.1.0",
30
- "react-query": "^3.39.2",
31
- "uuid": "^9.0.0"
32
- },
33
- "devDependencies": {
34
- "@babel/preset-env": "^7.19.1",
35
- "@babel/preset-react": "^7.18.6",
36
- "@babel/preset-typescript": "^7.18.6",
37
- "@types/react": "^18.0.20",
38
- "eslint": "^8.33.0",
39
- "eslint-config-standard": "^17.0.0",
40
- "eslint-plugin-import": "^2.27.5",
41
- "eslint-plugin-n": "^15.6.1",
42
- "eslint-plugin-promise": "^6.1.1",
43
- "eslint-plugin-react": "^7.32.2",
44
- "eslint-plugin-react-hooks": "^4.6.0"
45
- }
46
- }
1
+ {
2
+ "name": "npm-pkg-hook",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/Jesus123780/pkg-hook"
6
+ },
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "version": "1.1.4",
11
+ "description": "description-pkg-hook",
12
+ "main": "/src/index.jsx",
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "lint": "eslint .",
16
+ "rm": "rm -rf node_modules package-lock.json && npm i"
17
+ },
18
+ "author": "",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "@apollo/client": "3.6.9",
22
+ "@typescript-eslint/parser": "^5.37.0",
23
+ "js-cookie": "3.0.1",
24
+ "lodash": "^4.17.21",
25
+ "moment": "^2.29.4",
26
+ "react": "18.1.0",
27
+ "react-dom": "18.1.0",
28
+ "react-query": "^3.39.2"
29
+ },
30
+ "devDependencies": {
31
+ "@babel/preset-env": "^7.19.1",
32
+ "@babel/preset-react": "^7.18.6",
33
+ "@babel/preset-typescript": "^7.18.6",
34
+ "@types/react": "^18.0.20",
35
+ "eslint": "^8.33.0",
36
+ "eslint-config-standard": "^17.0.0",
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",
41
+ "eslint-plugin-react-hooks": "^4.6.0"
42
+ }
43
+ }
@@ -4,8 +4,7 @@ export const errorHandler = (error) => {
4
4
  let logout = null
5
5
  if (error) {
6
6
  error.errors?.length && error.errors.forEach(err => {
7
- const { code } = err.extensions
8
- const { message } = err
7
+ const { code, message: { message } } = err.extensions
9
8
  if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
10
9
  logout = true
11
10
  return {
@@ -1,31 +1,35 @@
1
-
2
- export * from './getSession'
3
1
  export * from './updateExtProductFoodsOptional'
4
2
  export * from './useAcumulateDate'
5
3
  export * from './useBanner'
6
- export * from './useCategoriesProduct'
7
4
  export * from './useCategoryInStore'
8
5
  export * from './useCategoryStore'
9
- export * from './useGenerateNumberArray'
10
- export * from './useAnimationFrame'
11
- export * from './useProviders'
12
6
  export * from './useCatWithProduct'
13
- export * from './useDropzone'
14
- export * from './useFingerprintjs'
7
+ export * from './useManageQueryParams'
8
+ export * from './useCategoriesProduct'
15
9
  export * from './useChartData'
10
+ export * from './useLogout'
16
11
  export * from './useStatusOpenStore'
12
+ export * from './useSchedule'
13
+ export * from './useScheduleData'
14
+ export * from './useImagesStore'
15
+ export * from './useFingerprintjs'
16
+ export * from './useEmployee'
17
17
  export * from './useCheckbox'
18
+ export * from './useRemoveExtraProductFoodsOptional'
19
+ export * from './useDeleteSubProductOptional'
20
+ export * from './useRatingData'
21
+ export * from './useChartData'
18
22
  export * from './useDevices'
19
- export * from './useScheduleData'
23
+ export * from './useSales'
20
24
  export * from './useClients'
21
- export * from './useDynamicAuth'
22
- export * from './useFullScreenMode'
25
+ export * from './useScroll'
26
+ export * from './useOrders'
27
+ export * from './useUpdateExistingOrders'
23
28
  export * from './useConnection'
24
29
  export * from './useCreateProduct'
25
30
  export * from './useCreateProduct/helpers/useEditImageProduct'
26
31
  export * from './useDessert'
27
32
  export * from './useDrag'
28
- export * from './useEmployee'
29
33
  export * from './useEvent'
30
34
  export * from './useFetchJson'
31
35
  export * from './useFormatDate'
@@ -40,35 +44,26 @@ export * from './useKeypress'
40
44
  export * from './useLazyScript'
41
45
  export * from './useLocalSorage'
42
46
  export * from './useLocationNavigate'
43
- export * from './useLogout'
44
- export * from './useManageQueryParams'
47
+ export * from './useSetSession'
45
48
  export * from './useMobile'
46
49
  export * from './useMutateHeight'
47
- export * from './useOrders'
48
- export * from './useScroll'
49
50
  export * from './useProductsFood'
50
- export * from './useProductsFood/queriesStore'
51
51
  export * from './useProductsFood/usetagsProducts'
52
52
  export * from './useReactToPrint'
53
- export * from './useRemoveExtraProductFoodsOptional'
54
53
  export * from './useReport'
54
+ // hola
55
+ export * from './useStoreContacts'
55
56
  export * from './useRestaurant'
56
57
  export * from './useSales'
57
58
  export * from './useSales/useGetSale'
58
59
  export * from './useSales/useTotalSales'
59
60
  export * from './useSaveAvailableProduct'
60
61
  export * from './useSchedule'
61
- export * from './useScrollRotate'
62
- export * from './useSetSession'
63
- export * from './useDeleteSubProductOptional'
64
62
  export * from './useSetState'
65
63
  export * from './useStore'
66
- export * from './useAnimationText'
67
64
  export * from './useStoreCalendar'
68
- export * from './useStoreContacts'
69
65
  export * from './useTimeAgo/useTimeAgo'
70
66
  export * from './useUpdateCart'
71
- export * from './useUpdateExistingOrders'
72
67
  export * from './useUpdateExtProductFoodsSubOptional'
73
68
  export * from './useUser'
74
- export * from './useRatingData'
69
+
@@ -1,29 +1,31 @@
1
- import {
2
- useEffect,
3
- useRef,
4
- useState
5
- } from 'react'
1
+ import { useEffect, useRef, useState } from 'react'
6
2
 
7
- const fullText = '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.'
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.'
8
5
 
9
6
  export const useAnimatedText = textMessage => {
10
7
  const fullTextRef = useRef(textMessage)
11
8
  const [text, setText] = useState('')
12
9
  const [index, setIndex] = useState(0)
10
+
13
11
  useEffect(() => {
14
12
  if (index < fullText.length) {
15
13
  window.requestAnimationFrame(() => {
16
14
  // eslint-disable-next-line
17
- setText(text => text + fullTextRef.current[index]);
18
- setIndex(() => { return index + 1 })
15
+ setText(text => text + fullTextRef.current[index]);
16
+ setIndex(() => {return index + 1})
19
17
  })
20
18
  }
21
19
  }, [index])
22
20
  useEffect(() => {
23
- if (fullText?.current) {
24
- fullText.current = textMessage
25
- }
21
+ fullText.current = textMessage
26
22
  }, [textMessage])
27
23
 
28
24
  return text
29
25
  }
26
+
27
+ // export default function TextHook() {
28
+ // const text = useAnimatedText(fullText)
29
+
30
+ // return <span>{text} </span>
31
+ // }
@@ -1,57 +1,24 @@
1
1
  import { useQuery } from '@apollo/client'
2
2
  import { GET_ALL_CATEGORIES_WITH_PRODUCT } from './queries'
3
- import { useLogout } from '../useLogout'
4
- import { errorHandler } from '../../config/client'
5
3
 
6
- /**
7
- * Custom hook to fetch categories with products based on given parameters.
8
- *
9
- * @param {Object} options - The options object with parameters for the query.
10
- * @param {number} options.max - Maximum price for product filtering.
11
- * @param {number} options.min - Minimum price for product filtering.
12
- * @param {string|null} options.search - Search query for product names.
13
- * @param {string|null} options.productName - Name of the product to search for.
14
- * @param {Object} options.searchFilter - Additional filters for product search.
15
- * @param {string} options.searchFilter.gender - Gender filter for products.
16
- * @param {string} options.searchFilter.desc - Description filter for products.
17
- * @param {string} options.searchFilter.speciality - Speciality filter for products.
18
- * @returns {[Object[], Object]} - An array with the list of categories with products and an object containing loading, error, fetchMore, and totalCount properties.
19
- */
20
4
  export const useCatWithProduct = ({
21
- max = 400,
5
+ max = 1,
22
6
  min = 0,
23
7
  search = null,
24
8
  productName = null,
25
9
  searchFilter= {}
26
- } = {}) => {
27
- const [onClickLogout] = useLogout()
28
-
29
- const {
10
+ }) => {
11
+ const {
30
12
  gender,
31
13
  desc,
32
14
  speciality
33
15
  } = searchFilter || {}
34
-
35
16
  const {
36
17
  data,
37
18
  loading,
38
19
  error,
39
20
  fetchMore
40
21
  } = useQuery(GET_ALL_CATEGORIES_WITH_PRODUCT, {
41
- onError: (error) => {
42
- const errors = {
43
- errors: error?.graphQLErrors || []
44
- }
45
- console.log(errors)
46
- const responseError = errorHandler(errors);
47
- console.log(responseError)
48
-
49
- if (error.message === 'Token expired' || responseError) {
50
- onClickLogout()
51
- }
52
-
53
- },
54
- notifyOnNetworkStatusChange: true,
55
22
  fetchPolicy: 'network-only',
56
23
  variables:
57
24
  {
@@ -59,7 +26,7 @@ export const useCatWithProduct = ({
59
26
  productName,
60
27
  gender: gender,
61
28
  min,
62
- max: max,
29
+ max: 400,
63
30
  desc: desc,
64
31
  categories: speciality
65
32
  }
@@ -23,6 +23,14 @@ getPromoStoreAdmin(min: $min, max: $max){
23
23
  }
24
24
  `
25
25
 
26
+ export const CREATE_STORE_CALENDAR = gql`
27
+ mutation setStoreSchedule($input: ITstoreSchedule!){
28
+ setStoreSchedule(input: $input){
29
+ message
30
+ success
31
+ }
32
+ }
33
+ `
26
34
  export const DELETE_ONE_CAT_PRODUCTS = gql`
27
35
  mutation deleteCatOfProducts($idPc: ID!, $pState: Int){
28
36
  deleteCatOfProducts(idPc: $idPc, pState: $pState){
@@ -56,6 +64,14 @@ mutation editExtProductFoods($input: InputExtProductFood!) {
56
64
  }
57
65
  }
58
66
  `
67
+ export const DELETE_CAT_EXTRA_PRODUCTS = gql`
68
+ mutation DeleteExtProductFoodsOptional($opExPid: ID, $state: Int){
69
+ DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state){
70
+ success,
71
+ message
72
+ }
73
+ }
74
+ `
59
75
  export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
60
76
  mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int){
61
77
  DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state){