npm-pkg-hook 1.1.5 → 1.1.8
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 +19 -113
- package/.eslintrc.json +127 -108
- package/next.config.js +2 -5
- package/package.json +27 -24
- package/src/config/client/errors.js +14 -14
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
- package/src/hooks/getCategoriesWithProduct/index.js +62 -0
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/index.js +13 -9
- package/src/hooks/useAcumulateDate/index.js +1 -1
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/helpers/index.js +22 -0
- package/src/hooks/useAsideCart/index.js +156 -0
- package/src/hooks/useAsideCart/queries.js +10 -0
- package/src/hooks/useBanner/index.js +11 -11
- package/src/hooks/useCart/index.js +2 -0
- package/src/hooks/useCart/queries.js +164 -0
- package/src/hooks/useCart/useCart/helpers/index.js +75 -0
- package/src/hooks/useCart/useCart/index.js +411 -0
- package/src/hooks/useCart/useGetCart/index.js +31 -0
- package/src/hooks/useCatWithProduct/index.js +15 -15
- package/src/hooks/useCatWithProduct/queries.js +1 -1
- package/src/hooks/useCatWithProductClient/index.js +48 -0
- package/src/hooks/useCatWithProductClient/queries.js +55 -0
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/index.js +39 -36
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useCategoryStore/index.js +2 -2
- package/src/hooks/useChartData/index.js +159 -156
- package/src/hooks/useChartData/useChartData/index.js +199 -197
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useClients/index.js +12 -14
- package/src/hooks/useClients/queries.js +1 -1
- package/src/hooks/useConnection/index.js +20 -21
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
- package/src/hooks/useCreateProduct/index.js +22 -19
- package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDessert/index.js +56 -65
- package/src/hooks/useDevices/index.js +35 -36
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -79
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEmployee/queries.js +1 -1
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -0
- package/src/hooks/useFavoriteStores/queries.js +47 -0
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -176
- package/src/hooks/useFormTools/index.js +12 -11
- package/src/hooks/useFormatDate/index.js +20 -21
- package/src/hooks/useFormatNumberPhone/index.js +9 -9
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
- package/src/hooks/useGetFoodRecomended/index.js +33 -0
- package/src/hooks/useGetFoodRecomended/queries.js +47 -0
- package/src/hooks/useGetMinPrice/index.js +8 -0
- package/src/hooks/useGetMinPrice/queries.js +7 -0
- package/src/hooks/useGetOneStoreRating/index.js +40 -0
- package/src/hooks/useGetOneStoreRating/queries.js +18 -0
- package/src/hooks/useGoogleLogin/index.js +160 -161
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImageOptimization/index.js +15 -15
- package/src/hooks/useImageWeight/index.js +18 -19
- package/src/hooks/useImagesStore/index.js +139 -140
- package/src/hooks/useImagesStore/queries.js +19 -18
- package/src/hooks/useInnerHtml/index.js +39 -38
- package/src/hooks/useIntersection/index.js +4 -4
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLazyScript/index.js +35 -36
- package/src/hooks/useLocalSorage/index.js +2 -2
- package/src/hooks/useLogout/index.js +23 -23
- package/src/hooks/useManageQueryParams/index.js +36 -37
- package/src/hooks/useMobile/index.js +39 -38
- package/src/hooks/useMutateHeight/index.js +15 -16
- package/src/hooks/useOrderClient/index.js +5 -0
- package/src/hooks/useOrders/index.js +10 -16
- package/src/hooks/useOrders/queries.js +1 -1
- package/src/hooks/useProductsFood/index.js +32 -32
- package/src/hooks/useProductsFood/queriesStore.js +49 -48
- package/src/hooks/useProductsFood/useEditProduct.js +2 -4
- package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
- package/src/hooks/useProvidersStore/index.js +24 -24
- package/src/hooks/useProvidersStore/queries.js +31 -31
- package/src/hooks/useRatingArrayData/index.js +54 -0
- package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
- package/src/hooks/useReactToPrint/index.js +1120 -1098
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useReport/index.js +9 -9
- package/src/hooks/useReport/queries.js +1 -1
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/index.js +476 -451
- package/src/hooks/useSales/queries.js +14 -15
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSales/useTotalSales.js +18 -18
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
- package/src/hooks/useSaveAvailableProduct/index.js +16 -16
- package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
- package/src/hooks/useSchedule/index.js +33 -36
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +34 -35
- package/src/hooks/useScheduleData/index.js +123 -171
- package/src/hooks/useScroll/index.js +56 -57
- package/src/hooks/useScrollRotate/index.js +16 -14
- package/src/hooks/useSetSession/index.js +16 -16
- package/src/hooks/useSetState/index.js +3 -3
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
- package/src/hooks/useStatusOpenStore/index.js +172 -173
- package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
- package/src/hooks/useStatusOrdersClient/index.js +17 -0
- package/src/hooks/useStatusOrdersClient/queries.js +80 -0
- package/src/hooks/useStore/index.js +40 -25
- package/src/hooks/useStore/queries.js +162 -136
- package/src/hooks/useStoreCalendar/index.js +5 -7
- package/src/hooks/useStoreContacts/index.js +16 -16
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateCart/index.js +34 -28
- package/src/hooks/useUpdateExistingOrders/index.js +35 -35
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
- package/src/hooks/useUser/index.js +1 -1
- package/src/hooks/useUser/queries.js +1 -1
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -2
- package/src/utils/index.js +42 -45
- package/src/hooks/useRatingData/index.js +0 -53
- package/src/hooks/useSalesClient/index.js +0 -1
package/.eslintrc.js
CHANGED
|
@@ -1,132 +1,38 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
settings: {
|
|
3
|
+
react: {
|
|
4
|
+
version: 'detect'
|
|
5
|
+
}
|
|
6
|
+
},
|
|
2
7
|
env: {
|
|
3
8
|
browser: true,
|
|
4
9
|
es2021: true,
|
|
5
10
|
node: true
|
|
6
11
|
},
|
|
7
12
|
extends: [
|
|
8
|
-
'
|
|
9
|
-
'
|
|
13
|
+
'standard',
|
|
14
|
+
'plugin:react/recommended'
|
|
10
15
|
],
|
|
11
16
|
overrides: [
|
|
17
|
+
{
|
|
18
|
+
env: {
|
|
19
|
+
node: true
|
|
20
|
+
},
|
|
21
|
+
files: [
|
|
22
|
+
'.eslintrc.{js,cjs}'
|
|
23
|
+
],
|
|
24
|
+
parserOptions: {
|
|
25
|
+
sourceType: 'script'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
12
28
|
],
|
|
13
29
|
parserOptions: {
|
|
14
30
|
ecmaVersion: 'latest',
|
|
15
31
|
sourceType: 'module'
|
|
16
32
|
},
|
|
17
33
|
plugins: [
|
|
18
|
-
'react'
|
|
19
|
-
'react-hooks',
|
|
20
|
-
'@typescript-eslint'
|
|
34
|
+
'react'
|
|
21
35
|
],
|
|
22
36
|
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
37
|
}
|
|
132
38
|
}
|
package/.eslintrc.json
CHANGED
|
@@ -1,108 +1,127 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
{
|
|
2
|
+
"settings": {
|
|
3
|
+
"react": {
|
|
4
|
+
"version": "detect"
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"env": {
|
|
8
|
+
"browser": true,
|
|
9
|
+
"es2021": true,
|
|
10
|
+
"node": true
|
|
11
|
+
},
|
|
12
|
+
"extends": "eslint:recommended",
|
|
13
|
+
"parserOptions": {
|
|
14
|
+
"ecmaVersion": "latest",
|
|
15
|
+
"sourceType": "module"
|
|
16
|
+
},
|
|
17
|
+
"rules": {
|
|
18
|
+
"import/no-anonymous-default-export": ["error", {
|
|
19
|
+
"allowArray": false,
|
|
20
|
+
"allowArrowFunction": false,
|
|
21
|
+
"allowAnonymousClass": false,
|
|
22
|
+
"allowAnonymousFunction": false,
|
|
23
|
+
"allowCallExpression": true, // The true value here is for backward compatibility
|
|
24
|
+
"allowLiteral": false,
|
|
25
|
+
"allowObject": true // anonymous-default-export
|
|
26
|
+
}],
|
|
27
|
+
// react hooks validations
|
|
28
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
29
|
+
"react-hooks/rules-of-hooks": "error",
|
|
30
|
+
// allow jsx syntax in js files (for next.js project)
|
|
31
|
+
"react/jsx-filename-extension": [
|
|
32
|
+
1,
|
|
33
|
+
{
|
|
34
|
+
"extensions": [
|
|
35
|
+
".js",
|
|
36
|
+
".jsx",
|
|
37
|
+
".ts",
|
|
38
|
+
".tsx"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"quotes": [
|
|
43
|
+
2,
|
|
44
|
+
"single",
|
|
45
|
+
{
|
|
46
|
+
"avoidEscape": true,
|
|
47
|
+
"allowTemplateLiterals": true
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"consistent-return": 2,
|
|
51
|
+
"indent": [
|
|
52
|
+
2,
|
|
53
|
+
2,
|
|
54
|
+
{
|
|
55
|
+
"SwitchCase": 1
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"no-else-return": 1,
|
|
59
|
+
"semi": [
|
|
60
|
+
1,
|
|
61
|
+
"never"
|
|
62
|
+
],
|
|
63
|
+
"space-unary-ops": 2,
|
|
64
|
+
"comma-dangle": [
|
|
65
|
+
"error",
|
|
66
|
+
{
|
|
67
|
+
"arrays": "never",
|
|
68
|
+
"objects": "never",
|
|
69
|
+
"imports": "never",
|
|
70
|
+
"exports": "never",
|
|
71
|
+
"functions": "never"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"one-var": [
|
|
75
|
+
2,
|
|
76
|
+
"never"
|
|
77
|
+
],
|
|
78
|
+
"no-var": "error",
|
|
79
|
+
"arrow-body-style": [
|
|
80
|
+
"error",
|
|
81
|
+
"always"
|
|
82
|
+
],
|
|
83
|
+
"no-console": "error",
|
|
84
|
+
"no-multi-spaces": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
"exceptions": {
|
|
88
|
+
"BinaryExpression": true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"no-multiple-empty-lines": [
|
|
93
|
+
"error",
|
|
94
|
+
{
|
|
95
|
+
"max": 2,
|
|
96
|
+
"maxBOF": 2
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"jsx-quotes": [
|
|
100
|
+
"error",
|
|
101
|
+
"prefer-single"
|
|
102
|
+
],
|
|
103
|
+
"react/jsx-sort-props": [
|
|
104
|
+
"error",
|
|
105
|
+
{
|
|
106
|
+
"noSortAlphabetically": false
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"react/jsx-first-prop-new-line": [
|
|
110
|
+
"error",
|
|
111
|
+
"multiline"
|
|
112
|
+
],
|
|
113
|
+
"react/jsx-max-props-per-line": [
|
|
114
|
+
"error",
|
|
115
|
+
{
|
|
116
|
+
"maximum": {
|
|
117
|
+
"single": 2,
|
|
118
|
+
"multi": 1
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"react/jsx-closing-bracket-location": [
|
|
123
|
+
"error",
|
|
124
|
+
"line-aligned"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
package/next.config.js
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
const {
|
|
4
4
|
PHASE_DEVELOPMENT_SERVER,
|
|
5
5
|
PHASE_PRODUCTION_BUILD
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
6
|
} = require('next/constants')
|
|
8
7
|
const nextConfig = {
|
|
9
8
|
reactStrictMode: true
|
|
10
9
|
}
|
|
11
10
|
module.exports = (phase) => {
|
|
12
|
-
|
|
13
11
|
// npm run dev or next dev
|
|
14
12
|
const isDev = phase === PHASE_DEVELOPMENT_SERVER
|
|
15
13
|
// npm run build or next build
|
|
@@ -98,7 +96,6 @@ module.exports = (phase) => {
|
|
|
98
96
|
}
|
|
99
97
|
]
|
|
100
98
|
}
|
|
101
|
-
const basePath = ''
|
|
102
99
|
// puedes sobre escribir la ruta
|
|
103
100
|
const rewrites = () => {
|
|
104
101
|
return [
|
|
@@ -115,7 +112,7 @@ module.exports = (phase) => {
|
|
|
115
112
|
return {
|
|
116
113
|
env,
|
|
117
114
|
swcMinify: false,
|
|
118
|
-
images,
|
|
115
|
+
images,
|
|
119
116
|
headers,
|
|
120
117
|
optimizeFonts: false,
|
|
121
118
|
nextConfig,
|
|
@@ -126,4 +123,4 @@ module.exports = (phase) => {
|
|
|
126
123
|
resolveUniqueReactForHooks
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
|
-
// module.exports = nextConfig
|
|
126
|
+
// module.exports = nextConfig
|
package/package.json
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
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.5",
|
|
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
2
|
"author": "",
|
|
19
|
-
"license": "ISC",
|
|
20
3
|
"dependencies": {
|
|
21
4
|
"@apollo/client": "3.6.9",
|
|
22
5
|
"@typescript-eslint/parser": "^5.37.0",
|
|
@@ -28,17 +11,37 @@
|
|
|
28
11
|
"react-dom": "18.1.0",
|
|
29
12
|
"react-query": "^3.39.2"
|
|
30
13
|
},
|
|
14
|
+
"description": "description-pkg-hook",
|
|
31
15
|
"devDependencies": {
|
|
32
16
|
"@babel/preset-env": "^7.19.1",
|
|
33
17
|
"@babel/preset-react": "^7.18.6",
|
|
34
18
|
"@babel/preset-typescript": "^7.18.6",
|
|
35
19
|
"@types/react": "^18.0.20",
|
|
36
|
-
"eslint": "
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "5.29.0",
|
|
21
|
+
"@typescript-eslint/parser": "5.29.0",
|
|
22
|
+
"eslint": "^8.0.1",
|
|
37
23
|
"eslint-config-standard": "^17.0.0",
|
|
38
|
-
"eslint-plugin-import": "^2.
|
|
39
|
-
"eslint-plugin-n": "^15.
|
|
40
|
-
"eslint-plugin-promise": "^6.
|
|
41
|
-
"eslint-plugin-react": "^7.
|
|
24
|
+
"eslint-plugin-import": "^2.25.2",
|
|
25
|
+
"eslint-plugin-n": "^15.0.0",
|
|
26
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
27
|
+
"eslint-plugin-react": "^7.33.2",
|
|
42
28
|
"eslint-plugin-react-hooks": "^4.6.0"
|
|
43
|
-
}
|
|
44
|
-
|
|
29
|
+
},
|
|
30
|
+
"license": "ISC",
|
|
31
|
+
"main": "/src/index.jsx",
|
|
32
|
+
"name": "npm-pkg-hook",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/Jesus123780/pkg-hook"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"lint:fix": "npm run lint -- --fix",
|
|
43
|
+
"rm": "rm -rf node_modules package-lock.json && npm i",
|
|
44
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
45
|
+
},
|
|
46
|
+
"version": "1.1.8"
|
|
47
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { onError } from '@apollo/client/link/error'
|
|
2
2
|
|
|
3
3
|
export const errorHandler = (error) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let logout = null
|
|
5
|
+
if (error) {
|
|
6
|
+
error.errors?.length && error.errors.forEach(err => {
|
|
7
|
+
const { code, message: { message } } = err.extensions
|
|
8
|
+
if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
|
|
9
|
+
logout = true
|
|
10
10
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
status: 'FORBIDDEN',
|
|
12
|
+
message
|
|
14
13
|
}
|
|
14
|
+
}
|
|
15
15
|
})
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
}
|
|
17
|
+
return logout
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const errorLink = onError(({ graphQLErrors, networkError }) => {
|
|
21
|
-
|
|
21
|
+
if (graphQLErrors)graphQLErrors.map(({ message, location, path }) => { return console.log(`[GraphQL error]: Message: ${message}, Location: ${location}, Path: ${path}`) })
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
})
|
|
23
|
+
if (networkError) console.log(`[Network error]: ${networkError}`)
|
|
24
|
+
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './errors'
|
|
1
|
+
export * from './errors'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jaccardSimilarity } from './helpers'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get categories that contain products with names similar to the given product name.
|
|
5
|
+
* Uses the Jaccard similarity coefficient for string comparison.
|
|
6
|
+
* @param {Array} data - The array of categories with product information.
|
|
7
|
+
* @param {string} productName - The name of the product to search for.
|
|
8
|
+
* @param {number} similarityThreshold - The minimum similarity threshold for products (0.0 to 1.0).
|
|
9
|
+
* @returns {Array} - An array of categories containing similar products.
|
|
10
|
+
*/
|
|
11
|
+
export const getCategoriesWithProduct = (
|
|
12
|
+
data = [],
|
|
13
|
+
productName = '',
|
|
14
|
+
similarityThreshold = 0.0) => {
|
|
15
|
+
// Validate input data
|
|
16
|
+
if (!data || !Array.isArray(data)) {
|
|
17
|
+
return data || []
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof productName !== 'string' || productName.trim() === '') {
|
|
21
|
+
return data
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Convert product name to lowercase for case-insensitive comparison
|
|
25
|
+
const productNameLower = productName.toLowerCase()
|
|
26
|
+
|
|
27
|
+
// Use a Set to store unique product names for better performance
|
|
28
|
+
const uniqueProductNames = new Set()
|
|
29
|
+
|
|
30
|
+
// Store unique product names in the Set
|
|
31
|
+
data.forEach(category => {
|
|
32
|
+
if (category?.productFoodsAll && Array.isArray(category.productFoodsAll)) {
|
|
33
|
+
category.productFoodsAll.forEach(product => {
|
|
34
|
+
const productLower = product.pName.toLowerCase()
|
|
35
|
+
uniqueProductNames.add(productLower)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Filter categories that contain products with names similar to the given product name
|
|
41
|
+
const matchingCategories = data.filter(category => {
|
|
42
|
+
if (category?.productFoodsAll && Array.isArray(category.productFoodsAll)) {
|
|
43
|
+
const products = category.productFoodsAll.some(product => {
|
|
44
|
+
const productLower = product?.pName?.toLowerCase()
|
|
45
|
+
return jaccardSimilarity(productNameLower, productLower) >= similarityThreshold
|
|
46
|
+
})
|
|
47
|
+
return products
|
|
48
|
+
}
|
|
49
|
+
return false
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Find similar products in each matching category
|
|
53
|
+
const findProduct = matchingCategories?.map(categories => {
|
|
54
|
+
const similarProducts = categories.productFoodsAll.filter(product => {
|
|
55
|
+
const productLower = product?.pName?.toLowerCase()
|
|
56
|
+
return productLower.includes(productNameLower)
|
|
57
|
+
})
|
|
58
|
+
return similarProducts.length > 0 ? { ...categories, productFoodsAll: similarProducts } : null
|
|
59
|
+
}).filter(Boolean)
|
|
60
|
+
|
|
61
|
+
return findProduct
|
|
62
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export const getSession = async () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|