npm-pkg-hook 1.0.9 → 1.1.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/.eslintrc.js +132 -132
- package/next.config.js +0 -1
- package/package.json +46 -43
- package/src/config/client/errors.js +2 -1
- package/src/hooks/getSession/index.js +18 -0
- package/src/hooks/index.js +27 -6
- package/src/hooks/useAnimationFrame/index.js +45 -0
- package/src/hooks/useAnimationText/index.jsx +11 -13
- package/src/hooks/useCatWithProduct/index.js +37 -4
- package/src/hooks/useCatWithProduct/queries.js +0 -16
- package/src/hooks/useCategoriesProduct/index.js +12 -0
- package/src/hooks/useCategoriesProduct/queries.js +16 -0
- package/src/hooks/useChartData/index.js +182 -154
- package/src/hooks/useCheckbox/index.js +5 -1
- package/src/hooks/useClients/index.js +17 -8
- package/src/hooks/useCreateProduct/index.js +96 -66
- package/src/hooks/useDeleteSubProductOptional/index.js +30 -0
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -0
- package/src/hooks/useDessert/helpers/index.js +51 -0
- package/src/hooks/useDessert/index.js +319 -121
- package/src/hooks/useDevices/index.js +36 -0
- package/src/hooks/useDevices/queries.js +19 -0
- package/src/hooks/useDrag/index.js +1 -1
- package/src/hooks/useDropzone/index.js +79 -0
- package/src/hooks/useDynamicAuth/index.js +13 -0
- package/src/hooks/useDynamicAuth/queries.js +24 -0
- package/src/hooks/useEmployee/index.js +11 -8
- package/src/hooks/useFingerprintjs/index.js +176 -0
- package/src/hooks/useFormTools/index.js +1 -1
- package/src/hooks/useFullScreenMode/index.js +8 -9
- package/src/hooks/useGenerateNumberArray/index.js +17 -0
- package/src/hooks/useImagesStore/index.js +176 -143
- package/src/hooks/useImagesStore/queries.js +1 -28
- package/src/hooks/useKeypress/index.js +7 -1
- package/src/hooks/useLocalSorage/index.js +1 -1
- package/src/hooks/useLogout/index.js +22 -25
- package/src/hooks/useManageQueryParams/index.js +37 -0
- package/src/hooks/useProductsFood/index.js +19 -4
- package/src/hooks/useProductsFood/queriesStore.js +3 -16
- package/src/hooks/useProductsFood/useEditProduct.js +10 -0
- package/src/hooks/useProductsFood/usetagsProducts.js +30 -5
- package/src/hooks/useProviders/index.js +3 -0
- package/src/hooks/useProviders/queries.js +31 -0
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +13 -0
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -0
- package/src/hooks/useProvidersStore/index.js +24 -0
- package/src/hooks/useProvidersStore/queries.js +31 -0
- package/src/hooks/useRatingData/index.js +53 -0
- package/src/hooks/useRatingData/queries.js +18 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -0
- package/src/hooks/useReport/index.js +16 -7
- package/src/hooks/useReport/queries.js +47 -32
- package/src/hooks/useSales/index.js +53 -22
- package/src/hooks/useSales/queries.js +48 -38
- package/src/hooks/useSales/useGetAllSales/index.js +25 -0
- package/src/hooks/useSales/useGetSale.js +16 -2
- package/src/hooks/useSchedule/index.js +36 -0
- package/src/hooks/useSchedule/queries.js +35 -0
- package/src/hooks/useScheduleData/index.js +171 -0
- package/src/hooks/useScroll/index.js +57 -0
- package/src/hooks/useScrollRotate/index.js +14 -0
- package/src/hooks/useStatusOpenStore/helpers/index.js +102 -0
- package/src/hooks/useStatusOpenStore/index.js +173 -0
- package/src/hooks/useStore/index.js +30 -16
- package/src/hooks/useUpdateExistingOrders/index.js +91 -0
- package/src/hooks/useUser/index.js +7 -2
- package/src/hooks/useUser/queries.js +40 -0
- package/src/index.jsx +3 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -8
- package/src/hooks/useSchedule/index.jsx +0 -23
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
|
+
}
|
package/next.config.js
CHANGED
|
@@ -46,7 +46,6 @@ module.exports = (phase) => {
|
|
|
46
46
|
if (isProd) return 'http://localhost:3000/'
|
|
47
47
|
if (isStaging) return 'Title Stg'
|
|
48
48
|
})(),
|
|
49
|
-
// URL_BASE_WS
|
|
50
49
|
URL_ADMIN_SERVER: (() => {
|
|
51
50
|
if (isDev) return 'http://localhost:4000/'
|
|
52
51
|
// if (isDev) return 'https://server-image-food.herokuapp.com/'
|
package/package.json
CHANGED
|
@@ -1,43 +1,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.
|
|
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
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"react
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"eslint
|
|
39
|
-
"eslint-
|
|
40
|
-
"eslint-plugin-
|
|
41
|
-
"eslint-plugin-
|
|
42
|
-
|
|
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
|
+
}
|
|
@@ -4,7 +4,8 @@ export const errorHandler = (error) => {
|
|
|
4
4
|
let logout = null
|
|
5
5
|
if (error) {
|
|
6
6
|
error.errors?.length && error.errors.forEach(err => {
|
|
7
|
-
|
|
7
|
+
const { code } = err.extensions
|
|
8
|
+
const { message } = err
|
|
8
9
|
if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
|
|
9
10
|
logout = true
|
|
10
11
|
return {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const getSession = async () => {
|
|
2
|
+
try {
|
|
3
|
+
const res = await fetch(`${process.env.URL_BASE}api/auth/getAuth`,
|
|
4
|
+
{ method: 'GET', headers: { 'Content-Type': 'application/json' } })
|
|
5
|
+
const data = await res.json()
|
|
6
|
+
const { ok, ok: { user }, isSession } = data || {}
|
|
7
|
+
const { deviceid, token } = user || {}
|
|
8
|
+
return {
|
|
9
|
+
user,
|
|
10
|
+
ok,
|
|
11
|
+
isSession,
|
|
12
|
+
deviceid,
|
|
13
|
+
token
|
|
14
|
+
}
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return e
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/hooks/index.js
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export * from './getSession'
|
|
1
3
|
export * from './updateExtProductFoodsOptional'
|
|
2
4
|
export * from './useAcumulateDate'
|
|
3
5
|
export * from './useBanner'
|
|
6
|
+
export * from './useCategoriesProduct'
|
|
4
7
|
export * from './useCategoryInStore'
|
|
5
8
|
export * from './useCategoryStore'
|
|
9
|
+
export * from './useGenerateNumberArray'
|
|
10
|
+
export * from './useAnimationFrame'
|
|
11
|
+
export * from './useProviders'
|
|
6
12
|
export * from './useCatWithProduct'
|
|
13
|
+
export * from './useDropzone'
|
|
14
|
+
export * from './useFingerprintjs'
|
|
7
15
|
export * from './useChartData'
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './useEmployee'
|
|
16
|
+
export * from './useStatusOpenStore'
|
|
10
17
|
export * from './useCheckbox'
|
|
18
|
+
export * from './useDevices'
|
|
19
|
+
export * from './useScheduleData'
|
|
11
20
|
export * from './useClients'
|
|
12
|
-
export * from './
|
|
21
|
+
export * from './useDynamicAuth'
|
|
22
|
+
export * from './useFullScreenMode'
|
|
13
23
|
export * from './useConnection'
|
|
14
24
|
export * from './useCreateProduct'
|
|
15
25
|
export * from './useCreateProduct/helpers/useEditImageProduct'
|
|
16
26
|
export * from './useDessert'
|
|
17
27
|
export * from './useDrag'
|
|
28
|
+
export * from './useEmployee'
|
|
18
29
|
export * from './useEvent'
|
|
19
30
|
export * from './useFetchJson'
|
|
20
31
|
export * from './useFormatDate'
|
|
@@ -29,25 +40,35 @@ export * from './useKeypress'
|
|
|
29
40
|
export * from './useLazyScript'
|
|
30
41
|
export * from './useLocalSorage'
|
|
31
42
|
export * from './useLocationNavigate'
|
|
32
|
-
export * from './
|
|
43
|
+
export * from './useLogout'
|
|
44
|
+
export * from './useManageQueryParams'
|
|
33
45
|
export * from './useMobile'
|
|
34
46
|
export * from './useMutateHeight'
|
|
47
|
+
export * from './useOrders'
|
|
48
|
+
export * from './useScroll'
|
|
35
49
|
export * from './useProductsFood'
|
|
50
|
+
export * from './useProductsFood/queriesStore'
|
|
36
51
|
export * from './useProductsFood/usetagsProducts'
|
|
37
52
|
export * from './useReactToPrint'
|
|
53
|
+
export * from './useRemoveExtraProductFoodsOptional'
|
|
38
54
|
export * from './useReport'
|
|
39
|
-
export * from './useStoreContacts'
|
|
40
55
|
export * from './useRestaurant'
|
|
41
56
|
export * from './useSales'
|
|
42
57
|
export * from './useSales/useGetSale'
|
|
43
58
|
export * from './useSales/useTotalSales'
|
|
44
59
|
export * from './useSaveAvailableProduct'
|
|
45
60
|
export * from './useSchedule'
|
|
61
|
+
export * from './useScrollRotate'
|
|
62
|
+
export * from './useSetSession'
|
|
63
|
+
export * from './useDeleteSubProductOptional'
|
|
46
64
|
export * from './useSetState'
|
|
47
65
|
export * from './useStore'
|
|
66
|
+
export * from './useAnimationText'
|
|
48
67
|
export * from './useStoreCalendar'
|
|
68
|
+
export * from './useStoreContacts'
|
|
49
69
|
export * from './useTimeAgo/useTimeAgo'
|
|
50
70
|
export * from './useUpdateCart'
|
|
71
|
+
export * from './useUpdateExistingOrders'
|
|
51
72
|
export * from './useUpdateExtProductFoodsSubOptional'
|
|
52
73
|
export * from './useUser'
|
|
53
|
-
|
|
74
|
+
export * from './useRatingData'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react"
|
|
2
|
+
|
|
3
|
+
export const useAnimationFrame = (callback, start, end, duration = 1000) => {
|
|
4
|
+
const functionRef = useRef()
|
|
5
|
+
const delta = Math.abs(start - end)
|
|
6
|
+
const frameCount = Math.ceil(60 * (duration / 1000))
|
|
7
|
+
const iteration = useRef(frameCount)
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const animate = (rafId) => {
|
|
10
|
+
if (iteration.current <= 0) {
|
|
11
|
+
cancelAnimationFrame(rafId)
|
|
12
|
+
iteration.current = frameCount
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
callback(Math.max(delta / iteration.current, 1))
|
|
16
|
+
iteration.current--
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (delta > 0) functionRef.current = requestAnimationFrame(animate)
|
|
20
|
+
|
|
21
|
+
return () => {return cancelAnimationFrame(functionRef.current)}
|
|
22
|
+
}, [callback, delta, frameCount, iteration])
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// const Counter = ({ numeral = 0 }) => {
|
|
26
|
+
// const [currentValue, setCurrentValue] = useState(0)
|
|
27
|
+
// const fxOperator = currentValue > numeral ? 'subtraction' : 'addition'
|
|
28
|
+
|
|
29
|
+
// useAnimationFrame(
|
|
30
|
+
// (diffValue) => {
|
|
31
|
+
// // Pass on a function to the setter of the state
|
|
32
|
+
// // to make sure we always have the latest state
|
|
33
|
+
// setCurrentValue((prevCount) => {
|
|
34
|
+
// return fxOperator === 'addition'
|
|
35
|
+
// ? prevCount + diffValue
|
|
36
|
+
// : prevCount - diffValue
|
|
37
|
+
// }
|
|
38
|
+
// )
|
|
39
|
+
// },
|
|
40
|
+
// currentValue,
|
|
41
|
+
// numeral,
|
|
42
|
+
// 300
|
|
43
|
+
// )
|
|
44
|
+
// return <>{new Intl.NumberFormat().format(Math.round(currentValue))}</>
|
|
45
|
+
// }
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useRef,
|
|
4
|
+
useState
|
|
5
|
+
} from 'react'
|
|
2
6
|
|
|
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.'
|
|
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.'
|
|
5
8
|
|
|
6
9
|
export const useAnimatedText = textMessage => {
|
|
7
10
|
const fullTextRef = useRef(textMessage)
|
|
8
11
|
const [text, setText] = useState('')
|
|
9
12
|
const [index, setIndex] = useState(0)
|
|
10
|
-
|
|
11
13
|
useEffect(() => {
|
|
12
14
|
if (index < fullText.length) {
|
|
13
15
|
window.requestAnimationFrame(() => {
|
|
14
16
|
// eslint-disable-next-line
|
|
15
|
-
|
|
16
|
-
setIndex(() => {return index + 1})
|
|
17
|
+
setText(text => text + fullTextRef.current[index]);
|
|
18
|
+
setIndex(() => { return index + 1 })
|
|
17
19
|
})
|
|
18
20
|
}
|
|
19
21
|
}, [index])
|
|
20
22
|
useEffect(() => {
|
|
21
|
-
fullText
|
|
23
|
+
if (fullText?.current) {
|
|
24
|
+
fullText.current = textMessage
|
|
25
|
+
}
|
|
22
26
|
}, [textMessage])
|
|
23
27
|
|
|
24
28
|
return text
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
// export default function TextHook() {
|
|
28
|
-
// const text = useAnimatedText(fullText)
|
|
29
|
-
|
|
30
|
-
// return <span>{text} </span>
|
|
31
|
-
// }
|
|
@@ -1,24 +1,57 @@
|
|
|
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'
|
|
3
5
|
|
|
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
|
+
*/
|
|
4
20
|
export const useCatWithProduct = ({
|
|
5
|
-
max =
|
|
21
|
+
max = 400,
|
|
6
22
|
min = 0,
|
|
7
23
|
search = null,
|
|
8
24
|
productName = null,
|
|
9
25
|
searchFilter= {}
|
|
10
|
-
}) => {
|
|
11
|
-
|
|
26
|
+
} = {}) => {
|
|
27
|
+
const [onClickLogout] = useLogout()
|
|
28
|
+
|
|
29
|
+
const {
|
|
12
30
|
gender,
|
|
13
31
|
desc,
|
|
14
32
|
speciality
|
|
15
33
|
} = searchFilter || {}
|
|
34
|
+
|
|
16
35
|
const {
|
|
17
36
|
data,
|
|
18
37
|
loading,
|
|
19
38
|
error,
|
|
20
39
|
fetchMore
|
|
21
40
|
} = 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,
|
|
22
55
|
fetchPolicy: 'network-only',
|
|
23
56
|
variables:
|
|
24
57
|
{
|
|
@@ -26,7 +59,7 @@ export const useCatWithProduct = ({
|
|
|
26
59
|
productName,
|
|
27
60
|
gender: gender,
|
|
28
61
|
min,
|
|
29
|
-
max:
|
|
62
|
+
max: max,
|
|
30
63
|
desc: desc,
|
|
31
64
|
categories: speciality
|
|
32
65
|
}
|
|
@@ -23,14 +23,6 @@ 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
|
-
`
|
|
34
26
|
export const DELETE_ONE_CAT_PRODUCTS = gql`
|
|
35
27
|
mutation deleteCatOfProducts($idPc: ID!, $pState: Int){
|
|
36
28
|
deleteCatOfProducts(idPc: $idPc, pState: $pState){
|
|
@@ -64,14 +56,6 @@ mutation editExtProductFoods($input: InputExtProductFood!) {
|
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
58
|
`
|
|
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
|
-
`
|
|
75
59
|
export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
|
|
76
60
|
mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int){
|
|
77
61
|
DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state){
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { GET_ULTIMATE_CATEGORY_PRODUCTS } from './queries'
|
|
3
|
+
|
|
4
|
+
export const useCategoriesProduct = () => {
|
|
5
|
+
const {
|
|
6
|
+
data,
|
|
7
|
+
loading,
|
|
8
|
+
error,
|
|
9
|
+
networkStatus
|
|
10
|
+
} = useQuery(GET_ULTIMATE_CATEGORY_PRODUCTS)
|
|
11
|
+
return [data?.catProductsAll, { loading, error, networkStatus }]
|
|
12
|
+
}
|