@bigbinary/neeto-commons-rn 1.8.3 → 1.8.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.
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// Shared ESLint 9 flat config for neeto React Native apps.
|
|
2
|
+
//
|
|
3
|
+
// Usage in an app's eslint.config.js:
|
|
4
|
+
//
|
|
5
|
+
// const neetoRNConfig = require("@bigbinary/neeto-commons-rn/eslint-config");
|
|
6
|
+
// const aliases = require("./aliases.json");
|
|
7
|
+
//
|
|
8
|
+
// module.exports = neetoRNConfig({ aliases });
|
|
9
|
+
//
|
|
10
|
+
// The plugins are resolved from the consuming app's node_modules — install
|
|
11
|
+
// the packages listed under peerDependencies (lint group) as devDependencies.
|
|
12
|
+
const babelParser = require("@babel/eslint-parser");
|
|
13
|
+
const js = require("@eslint/js");
|
|
14
|
+
const prettierConfig = require("eslint-config-prettier");
|
|
15
|
+
const importPlugin = require("eslint-plugin-import");
|
|
16
|
+
const prettierPlugin = require("eslint-plugin-prettier");
|
|
17
|
+
const promisePlugin = require("eslint-plugin-promise");
|
|
18
|
+
const reactPlugin = require("eslint-plugin-react");
|
|
19
|
+
const reactHooksPlugin = require("eslint-plugin-react-hooks");
|
|
20
|
+
const reactNativePlugin = require("eslint-plugin-react-native");
|
|
21
|
+
const unusedImportsPlugin = require("eslint-plugin-unused-imports");
|
|
22
|
+
const globals = require("globals");
|
|
23
|
+
|
|
24
|
+
const neetoPlugin = {
|
|
25
|
+
rules: {
|
|
26
|
+
"no-dangling-constants": require("./rules/no-dangling-constants"),
|
|
27
|
+
"no-redundant-string-templates": require("./rules/no-redundant-string-templates"),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const DEFAULT_IGNORES = [
|
|
32
|
+
"node_modules/**",
|
|
33
|
+
"android/**",
|
|
34
|
+
"ios/**",
|
|
35
|
+
"vendor/**",
|
|
36
|
+
"coverage/**",
|
|
37
|
+
"patches/**",
|
|
38
|
+
"**/*.json",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
module.exports = ({ aliases = {}, ignores = [] } = {}) => [
|
|
42
|
+
{
|
|
43
|
+
ignores: [...DEFAULT_IGNORES, ...ignores],
|
|
44
|
+
},
|
|
45
|
+
js.configs.recommended,
|
|
46
|
+
reactPlugin.configs.flat.recommended,
|
|
47
|
+
promisePlugin.configs["flat/recommended"],
|
|
48
|
+
{
|
|
49
|
+
files: ["**/*.{js,jsx}"],
|
|
50
|
+
languageOptions: {
|
|
51
|
+
parser: babelParser,
|
|
52
|
+
ecmaVersion: "latest",
|
|
53
|
+
sourceType: "module",
|
|
54
|
+
parserOptions: {
|
|
55
|
+
ecmaFeatures: { jsx: true },
|
|
56
|
+
},
|
|
57
|
+
globals: {
|
|
58
|
+
...globals.browser,
|
|
59
|
+
...globals.node,
|
|
60
|
+
...globals.es2021,
|
|
61
|
+
...globals.jest,
|
|
62
|
+
...(reactNativePlugin.environments?.["react-native"]?.globals ?? {}),
|
|
63
|
+
Atomics: "readonly",
|
|
64
|
+
SharedArrayBuffer: "readonly",
|
|
65
|
+
// Makes logger function available everywhere. Else eslint will complain of undef-var.
|
|
66
|
+
logger: "readonly",
|
|
67
|
+
globalProps: "readonly",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
plugins: {
|
|
71
|
+
react: reactPlugin,
|
|
72
|
+
"react-native": reactNativePlugin,
|
|
73
|
+
import: importPlugin,
|
|
74
|
+
"react-hooks": reactHooksPlugin,
|
|
75
|
+
"@bigbinary/neeto": neetoPlugin,
|
|
76
|
+
"unused-imports": unusedImportsPlugin,
|
|
77
|
+
prettier: prettierPlugin,
|
|
78
|
+
},
|
|
79
|
+
settings: {
|
|
80
|
+
react: {
|
|
81
|
+
version: "detect",
|
|
82
|
+
},
|
|
83
|
+
"import/resolver": {
|
|
84
|
+
"babel-module": {
|
|
85
|
+
root: ["."],
|
|
86
|
+
alias: aliases,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
"react-native/style-sheet-object-names": ["StyleSheet"],
|
|
90
|
+
},
|
|
91
|
+
rules: {
|
|
92
|
+
// Disable stylistic rules that conflict with Prettier, then let
|
|
93
|
+
// prettier/prettier report formatting drift.
|
|
94
|
+
...prettierConfig.rules,
|
|
95
|
+
"prettier/prettier": "error",
|
|
96
|
+
|
|
97
|
+
"@bigbinary/neeto/no-dangling-constants": 2,
|
|
98
|
+
"@bigbinary/neeto/no-redundant-string-templates": 2,
|
|
99
|
+
"import/no-unresolved": 2,
|
|
100
|
+
"require-await": 2,
|
|
101
|
+
"import/no-anonymous-default-export": 2,
|
|
102
|
+
"no-unused-vars": [
|
|
103
|
+
"error",
|
|
104
|
+
{
|
|
105
|
+
args: "all",
|
|
106
|
+
argsIgnorePattern: "^_",
|
|
107
|
+
destructuredArrayIgnorePattern: "^_",
|
|
108
|
+
caughtErrors: "all",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
"no-undef": "error",
|
|
112
|
+
// Dont use console statements. Use logger which babel will remove during bundling.
|
|
113
|
+
"no-console": "error",
|
|
114
|
+
"consistent-return": "error",
|
|
115
|
+
"padding-line-between-statements": [
|
|
116
|
+
"error",
|
|
117
|
+
{ blankLine: "always", prev: "if", next: ["if", "return"] },
|
|
118
|
+
{ blankLine: "always", prev: "*", next: "return" },
|
|
119
|
+
{
|
|
120
|
+
blankLine: "always",
|
|
121
|
+
prev: [
|
|
122
|
+
"block",
|
|
123
|
+
"multiline-block-like",
|
|
124
|
+
"function",
|
|
125
|
+
"iife",
|
|
126
|
+
"multiline-const",
|
|
127
|
+
"multiline-expression",
|
|
128
|
+
],
|
|
129
|
+
next: ["function", "iife", "multiline-const", "multiline-expression"],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
curly: ["error", "multi-line"],
|
|
133
|
+
"no-else-return": "error",
|
|
134
|
+
"comma-dangle": [
|
|
135
|
+
"error",
|
|
136
|
+
{
|
|
137
|
+
arrays: "always-multiline",
|
|
138
|
+
objects: "always-multiline",
|
|
139
|
+
imports: "always-multiline",
|
|
140
|
+
exports: "always-multiline",
|
|
141
|
+
functions: "never",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
"prefer-const": "error",
|
|
145
|
+
eqeqeq: "error",
|
|
146
|
+
"no-unsafe-optional-chaining": "error",
|
|
147
|
+
"unused-imports/no-unused-imports": "error",
|
|
148
|
+
"no-nested-ternary": "warn",
|
|
149
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
150
|
+
"prefer-template": "error",
|
|
151
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
152
|
+
"object-shorthand": [
|
|
153
|
+
"error",
|
|
154
|
+
"always",
|
|
155
|
+
{ avoidQuotes: true, ignoreConstructors: true },
|
|
156
|
+
],
|
|
157
|
+
"prefer-arrow-callback": ["error", { allowUnboundThis: true }],
|
|
158
|
+
"no-duplicate-imports": ["error", { includeExports: true }],
|
|
159
|
+
"no-implicit-coercion": ["error", { allow: ["!!"] }],
|
|
160
|
+
"no-var": "error",
|
|
161
|
+
|
|
162
|
+
// Promise hygiene.
|
|
163
|
+
"promise/prefer-await-to-then": 2,
|
|
164
|
+
"promise/no-nesting": 2,
|
|
165
|
+
"promise/prefer-await-to-callbacks": 2,
|
|
166
|
+
"promise/no-new-statics": "error",
|
|
167
|
+
|
|
168
|
+
// Imports.
|
|
169
|
+
"import/order": [
|
|
170
|
+
"error",
|
|
171
|
+
{
|
|
172
|
+
"newlines-between": "always",
|
|
173
|
+
alphabetize: { order: "asc", caseInsensitive: true },
|
|
174
|
+
warnOnUnassignedImports: true,
|
|
175
|
+
groups: [
|
|
176
|
+
"builtin",
|
|
177
|
+
"external",
|
|
178
|
+
"internal",
|
|
179
|
+
"index",
|
|
180
|
+
"sibling",
|
|
181
|
+
"parent",
|
|
182
|
+
"object",
|
|
183
|
+
"type",
|
|
184
|
+
],
|
|
185
|
+
pathGroups: [
|
|
186
|
+
{
|
|
187
|
+
pattern: "react+(-native|)",
|
|
188
|
+
group: "external",
|
|
189
|
+
position: "before",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
// Ignore react imports so that they're always ordered to the top of the file.
|
|
193
|
+
pathGroupsExcludedImportTypes: ["react", "react-native"],
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
"import/prefer-default-export": "off",
|
|
197
|
+
"import/no-cycle": ["error", { maxDepth: 1, ignoreExternal: true }],
|
|
198
|
+
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
|
|
199
|
+
"import/export": "error",
|
|
200
|
+
"import/no-mutable-exports": "error",
|
|
201
|
+
"import/first": "error",
|
|
202
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
203
|
+
"import/extensions": [
|
|
204
|
+
"error",
|
|
205
|
+
"never",
|
|
206
|
+
{
|
|
207
|
+
ignorePackages: true,
|
|
208
|
+
pattern: { json: "always", mp3: "always" },
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
|
|
212
|
+
// React.
|
|
213
|
+
"react/prop-types": "off",
|
|
214
|
+
"react/no-unescaped-entities": "off",
|
|
215
|
+
"react/display-name": "error",
|
|
216
|
+
"react/no-access-state-in-setstate": "error",
|
|
217
|
+
"react/no-danger": "warn",
|
|
218
|
+
"react/no-danger-with-children": "warn",
|
|
219
|
+
"react/no-unused-prop-types": "error",
|
|
220
|
+
"react/jsx-key": "error",
|
|
221
|
+
"react/jsx-no-duplicate-props": "error",
|
|
222
|
+
"react/jsx-no-undef": "error",
|
|
223
|
+
"react/jsx-pascal-case": [
|
|
224
|
+
"error",
|
|
225
|
+
{ allowNamespace: true, ignore: ["FAB"] },
|
|
226
|
+
],
|
|
227
|
+
"react/jsx-uses-react": "error",
|
|
228
|
+
"react/jsx-uses-vars": "error",
|
|
229
|
+
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
230
|
+
"react/function-component-definition": [
|
|
231
|
+
"error",
|
|
232
|
+
{
|
|
233
|
+
namedComponents: "arrow-function",
|
|
234
|
+
unnamedComponents: "arrow-function",
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
"react/self-closing-comp": [
|
|
238
|
+
"error",
|
|
239
|
+
{
|
|
240
|
+
component: true,
|
|
241
|
+
html: true,
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
"react/jsx-wrap-multilines": [
|
|
245
|
+
"error",
|
|
246
|
+
{
|
|
247
|
+
declaration: "parens-new-line",
|
|
248
|
+
assignment: "parens-new-line",
|
|
249
|
+
return: "parens-new-line",
|
|
250
|
+
arrow: "parens-new-line",
|
|
251
|
+
condition: "parens-new-line",
|
|
252
|
+
logical: "parens-new-line",
|
|
253
|
+
prop: "ignore",
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
"react/jsx-filename-extension": ["error", { allow: "as-needed" }],
|
|
257
|
+
"react/jsx-boolean-value": "error",
|
|
258
|
+
"react/hook-use-state": "error",
|
|
259
|
+
"react/jsx-sort-props": [
|
|
260
|
+
"error",
|
|
261
|
+
{
|
|
262
|
+
callbacksLast: true,
|
|
263
|
+
shorthandFirst: true,
|
|
264
|
+
multiline: "last",
|
|
265
|
+
reservedFirst: false,
|
|
266
|
+
locale: "auto",
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
"react/jsx-curly-brace-presence": [
|
|
270
|
+
"error",
|
|
271
|
+
{
|
|
272
|
+
props: "never",
|
|
273
|
+
children: "never",
|
|
274
|
+
propElementValues: "always",
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
"react/jsx-newline": ["error", { prevent: true }],
|
|
278
|
+
// allowAsProps: React Navigation (tabBarIcon) and neetoui-rn
|
|
279
|
+
// (SuffixIcon, RightComponent) take render-prop components.
|
|
280
|
+
"react/no-unstable-nested-components": ["error", { allowAsProps: true }],
|
|
281
|
+
|
|
282
|
+
"react-hooks/rules-of-hooks": "error",
|
|
283
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
284
|
+
|
|
285
|
+
"react-native/no-unused-styles": 2,
|
|
286
|
+
"react-native/split-platform-components": 1,
|
|
287
|
+
"react-native/no-inline-styles": 1,
|
|
288
|
+
"react-native/no-raw-text": 0,
|
|
289
|
+
"react-native/no-single-element-style-arrays": 1,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
files: ["*.config.js", ".prettierrc.js", "babel.config.js"],
|
|
294
|
+
rules: {
|
|
295
|
+
"import/order": "off",
|
|
296
|
+
"react-hooks/rules-of-hooks": "off",
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Vendored from neetozone/eslint-plugin-neeto (src/lib/rules/constants/
|
|
2
|
+
// no-dangling-constants.js) so the plugin — and its hard dependency on
|
|
3
|
+
// neeto-commons-frontend — is not needed for the two rules this app uses.
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const CONSTANT_CASE_PATTERN = /^[A-Z0-9_]*$/;
|
|
7
|
+
const CONSTANTS_FILES = [/constants\//, /.*constants.(js|jsx)$/i];
|
|
8
|
+
|
|
9
|
+
const isConstantsFile = filename =>
|
|
10
|
+
CONSTANTS_FILES.some(pattern => pattern.test(path.resolve(filename)));
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
meta: {
|
|
14
|
+
type: "suggestion",
|
|
15
|
+
docs: {
|
|
16
|
+
url: "https://github.com/neetozone/eslint-plugin-neeto/blob/main/docs/src/rules/no-dangling-constants.md",
|
|
17
|
+
description:
|
|
18
|
+
"Indicates that any constant outside a constant.[js|jsx] file should be moved to a constant.[js|jsx] file.",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
create: context => ({
|
|
22
|
+
VariableDeclaration(node) {
|
|
23
|
+
if (isConstantsFile(context.filename)) return;
|
|
24
|
+
if (node.kind !== "const") return;
|
|
25
|
+
|
|
26
|
+
const name = node.declarations[0]?.id?.name;
|
|
27
|
+
if (!name || !CONSTANT_CASE_PATTERN.test(name)) return;
|
|
28
|
+
|
|
29
|
+
context.report({
|
|
30
|
+
node,
|
|
31
|
+
message: `Move the constant ${name} to a constants.js file.`,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Vendored from neetozone/eslint-plugin-neeto (src/lib/rules/
|
|
2
|
+
// no-redundant-string-templates/) so the plugin — and its hard dependency on
|
|
3
|
+
// neeto-commons-frontend — is not needed for the two rules this app uses.
|
|
4
|
+
const CHARACTERS_TO_IGNORE_PATTERN = /[\r\n\t\f\v&><}"{'`\\]/;
|
|
5
|
+
const ENDS_WITH_SPACES_PATTERN = / +$/;
|
|
6
|
+
const STARTS_OR_ENDS_WITH_SPACES_PATTERN = /^ +| +$/;
|
|
7
|
+
const STARTS_WITH_SPACES_PATTERN = /^ +/;
|
|
8
|
+
|
|
9
|
+
const getCode = (context, node) =>
|
|
10
|
+
context.sourceCode.text.slice(node.range[0], node.range[1]);
|
|
11
|
+
|
|
12
|
+
const doQuasisHaveSpecialCharacters = node =>
|
|
13
|
+
node.quasis.some(quasi =>
|
|
14
|
+
CHARACTERS_TO_IGNORE_PATTERN.test(quasi.value.cooked)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const isExpressionOnly = node =>
|
|
18
|
+
node.expressions.length === 1 &&
|
|
19
|
+
node.quasis.length === 2 &&
|
|
20
|
+
node.quasis[0].value.cooked === "" &&
|
|
21
|
+
node.quasis[1].value.cooked === "";
|
|
22
|
+
|
|
23
|
+
const isInsideJsxElement = node =>
|
|
24
|
+
node.parent?.type === "JSXExpressionContainer" &&
|
|
25
|
+
["JSXElement", "JSXFragment"].includes(node.parent.parent?.type) &&
|
|
26
|
+
!STARTS_WITH_SPACES_PATTERN.test(node.quasis[0]?.value.cooked ?? "") &&
|
|
27
|
+
!ENDS_WITH_SPACES_PATTERN.test(
|
|
28
|
+
node.quasis[node.quasis.length - 1]?.value.cooked ?? ""
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const isReplaceableQuasisOnly = node =>
|
|
32
|
+
node.expressions.length === 0 &&
|
|
33
|
+
node.quasis.length === 1 &&
|
|
34
|
+
!STARTS_OR_ENDS_WITH_SPACES_PATTERN.test(node.quasis[0].value.cooked);
|
|
35
|
+
|
|
36
|
+
const getTemplateContent = (context, node) =>
|
|
37
|
+
node.expressions.reduce(
|
|
38
|
+
(acc, expression, index) =>
|
|
39
|
+
`${acc}{${getCode(context, expression)}}${
|
|
40
|
+
node.quasis[index + 1].value.cooked
|
|
41
|
+
}`,
|
|
42
|
+
node.quasis[0].value.cooked
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const canBeReplacedWith = fix => `Can be replaced with: ${fix}`;
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
meta: {
|
|
49
|
+
type: "problem",
|
|
50
|
+
docs: {
|
|
51
|
+
url: "https://github.com/neetozone/eslint-plugin-neeto/blob/main/docs/src/rules/no-redundant-string-templates.md",
|
|
52
|
+
description:
|
|
53
|
+
"Prevent usage of string templates as direct children of JSX components.",
|
|
54
|
+
},
|
|
55
|
+
fixable: "code",
|
|
56
|
+
},
|
|
57
|
+
create: context => ({
|
|
58
|
+
TemplateLiteral(node) {
|
|
59
|
+
if (doQuasisHaveSpecialCharacters(node)) return;
|
|
60
|
+
|
|
61
|
+
if (isExpressionOnly(node)) {
|
|
62
|
+
const fix = getCode(context, node.expressions[0]);
|
|
63
|
+
context.report({
|
|
64
|
+
node,
|
|
65
|
+
message: canBeReplacedWith(fix),
|
|
66
|
+
fix: fixer => fixer.replaceText(node, fix),
|
|
67
|
+
});
|
|
68
|
+
} else if (isInsideJsxElement(node)) {
|
|
69
|
+
const fix = getTemplateContent(context, node);
|
|
70
|
+
context.report({
|
|
71
|
+
node,
|
|
72
|
+
message: canBeReplacedWith(fix),
|
|
73
|
+
fix: fixer => fixer.replaceText(node.parent, fix),
|
|
74
|
+
});
|
|
75
|
+
} else if (isReplaceableQuasisOnly(node)) {
|
|
76
|
+
const fix = `"${node.quasis[0].value.cooked}"`;
|
|
77
|
+
context.report({
|
|
78
|
+
node,
|
|
79
|
+
message: canBeReplacedWith(fix),
|
|
80
|
+
fix: fixer => fixer.replaceText(node, fix),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useUpdateTeamMember=exports.useRemoveTeamMember=exports.useFetchTeamMembers=exports.useCreateMember=void 0;var _reactQuery=require("react-query");var _reactRedux=require("react-redux");var _team_members=_interopRequireDefault(require("../../api/team_members"));var _auth=require("../../auth");var _constants=require("./constants");var _queryKeys=require("./queryKeys");var getSearchParams=function getSearchParams(searchTerm){return[{conditions:[{type:"text",rule:"contains",node:"first_name,last_name,email",value:searchTerm}]}];};var useFetchTeamMembers=exports.useFetchTeamMembers=function useFetchTeamMembers(){var searchTerm=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";return(0,_reactQuery.useInfiniteQuery)([_queryKeys.queryKeys.TEAM_MEMBERS,searchTerm],function(_ref){var _ref$pageParam=_ref.pageParam,pageParam=_ref$pageParam===void 0?1:_ref$pageParam;var params={page:pageParam,page_size:_constants.PAGE_SIZE};if(searchTerm){params.neeto_filters=getSearchParams(searchTerm);}return _team_members.default.fetch(params);},{getNextPageParam:function getNextPageParam(lastPage,pages){var _pages$length,_lastPage$data$member,_lastPage$data,
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useUpdateTeamMember=exports.useRemoveTeamMember=exports.useFetchTeamMembers=exports.useCreateMember=void 0;var _reactQuery=require("react-query");var _reactRedux=require("react-redux");var _team_members=_interopRequireDefault(require("../../api/team_members"));var _auth=require("../../auth");var _constants=require("./constants");var _queryKeys=require("./queryKeys");var getSearchParams=function getSearchParams(searchTerm){return[{conditions:[{type:"text",rule:"contains",node:"first_name,last_name,email",value:searchTerm}]}];};var useFetchTeamMembers=exports.useFetchTeamMembers=function useFetchTeamMembers(){var searchTerm=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";return(0,_reactQuery.useInfiniteQuery)([_queryKeys.queryKeys.TEAM_MEMBERS,searchTerm],function(_ref){var _ref$pageParam=_ref.pageParam,pageParam=_ref$pageParam===void 0?1:_ref$pageParam;var params={page:pageParam,page_size:_constants.PAGE_SIZE};if(searchTerm){params.neeto_filters=getSearchParams(searchTerm);}return _team_members.default.fetch(params);},{getNextPageParam:function getNextPageParam(lastPage,pages){var _pages$length,_lastPage$data$member,_lastPage$data,_lastPage$data$member2,_lastPage$data2,_lastPage$data2$membe;var currPage=(_pages$length=pages==null?void 0:pages.length)!=null?_pages$length:0;var totalMembers=(_lastPage$data$member=lastPage==null?void 0:(_lastPage$data=lastPage.data)==null?void 0:_lastPage$data.members_count)!=null?_lastPage$data$member:0;var fetchedMembersCount=(currPage-1)*_constants.PAGE_SIZE+((_lastPage$data$member2=lastPage==null?void 0:(_lastPage$data2=lastPage.data)==null?void 0:(_lastPage$data2$membe=_lastPage$data2.members)==null?void 0:_lastPage$data2$membe.length)!=null?_lastPage$data$member2:0);return fetchedMembersCount>=totalMembers?undefined:currPage+1;},select:function select(data){return data.pages.flatMap(function(_ref2){var _ref2$data$members=_ref2.data.members,members=_ref2$data$members===void 0?[]:_ref2$data$members;return members;});}});};var useCreateMember=exports.useCreateMember=function useCreateMember(_ref3){var _onSuccess=_ref3.onSuccess;var queryClient=(0,_reactQuery.useQueryClient)();return(0,_reactQuery.useMutation)(function(_ref4){var payload=_ref4.payload;return _team_members.default.create(payload);},{onSuccess:function onSuccess(){queryClient.invalidateQueries(_queryKeys.queryKeys.TEAM_MEMBERS);_onSuccess==null?void 0:_onSuccess();}});};var useUpdateTeamMember=exports.useUpdateTeamMember=function useUpdateTeamMember(_ref5){var _onSuccess2=_ref5.onSuccess;var queryClient=(0,_reactQuery.useQueryClient)();return(0,_reactQuery.useMutation)(function(_ref6){var id=_ref6.id,payload=_ref6.payload;return _team_members.default.update(id,Object.assign({},payload,{active:true}));},{onSuccess:function onSuccess(){queryClient.invalidateQueries(_queryKeys.queryKeys.TEAM_MEMBERS);_onSuccess2==null?void 0:_onSuccess2();}});};var useRemoveTeamMember=exports.useRemoveTeamMember=function useRemoveTeamMember(){var queryClient=(0,_reactQuery.useQueryClient)();var userId=(0,_reactRedux.useSelector)(function(store){var _store$auth;return((_store$auth=store.auth)==null?void 0:_store$auth.userId)||"";});var dispatch=(0,_reactRedux.useDispatch)();return(0,_reactQuery.useMutation)(function(_ref7){var id=_ref7.id;return _team_members.default.update(id,{is_active:false});},{onSuccess:function onSuccess(_,_ref8){var id=_ref8.id;queryClient.invalidateQueries(_queryKeys.queryKeys.TEAM_MEMBERS);if(id===userId){dispatch((0,_auth.logoutUserAction)());}}});};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-rn",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"main": ".",
|
|
5
5
|
"files": [
|
|
6
6
|
"api",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"screens",
|
|
21
21
|
"assets",
|
|
22
22
|
"utils",
|
|
23
|
-
"
|
|
23
|
+
"eslint-config"
|
|
24
24
|
],
|
|
25
25
|
"husky": {
|
|
26
26
|
"hooks": {
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
31
32
|
"@bigbinary/app-version-control": "^1.1.6",
|
|
32
33
|
"@bigbinary/neetoui-rn": ">=2.0.0",
|
|
34
|
+
"@eslint/js": "^9.26.0",
|
|
33
35
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
34
36
|
"@react-navigation/bottom-tabs": "^6.5.3",
|
|
35
37
|
"@react-navigation/material-top-tabs": "^6.5.2",
|
|
@@ -37,6 +39,17 @@
|
|
|
37
39
|
"@react-navigation/native-stack": ">=6.9.8",
|
|
38
40
|
"axios": ">=1.16.0",
|
|
39
41
|
"dayjs": "^1.11.6",
|
|
42
|
+
"eslint": "^9.26.0",
|
|
43
|
+
"eslint-config-prettier": "^9.1.0",
|
|
44
|
+
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
45
|
+
"eslint-plugin-import": "^2.31.0",
|
|
46
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
47
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
48
|
+
"eslint-plugin-react": "^7.37.5",
|
|
49
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
50
|
+
"eslint-plugin-react-native": "^5.0.0",
|
|
51
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
52
|
+
"globals": "^15.15.0",
|
|
40
53
|
"react": ">=18.2.0 <19",
|
|
41
54
|
"react-native": ">=0.70.0",
|
|
42
55
|
"react-native-cam": "^5.4.16",
|
|
@@ -101,5 +114,46 @@
|
|
|
101
114
|
},
|
|
102
115
|
"resolutions": {
|
|
103
116
|
"cheerio": "1.0.0-rc.3"
|
|
117
|
+
},
|
|
118
|
+
"peerDependenciesMeta": {
|
|
119
|
+
"@babel/eslint-parser": {
|
|
120
|
+
"optional": true
|
|
121
|
+
},
|
|
122
|
+
"@eslint/js": {
|
|
123
|
+
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"eslint": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"eslint-config-prettier": {
|
|
129
|
+
"optional": true
|
|
130
|
+
},
|
|
131
|
+
"eslint-import-resolver-babel-module": {
|
|
132
|
+
"optional": true
|
|
133
|
+
},
|
|
134
|
+
"eslint-plugin-import": {
|
|
135
|
+
"optional": true
|
|
136
|
+
},
|
|
137
|
+
"eslint-plugin-prettier": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"eslint-plugin-promise": {
|
|
141
|
+
"optional": true
|
|
142
|
+
},
|
|
143
|
+
"eslint-plugin-react": {
|
|
144
|
+
"optional": true
|
|
145
|
+
},
|
|
146
|
+
"eslint-plugin-react-hooks": {
|
|
147
|
+
"optional": true
|
|
148
|
+
},
|
|
149
|
+
"eslint-plugin-react-native": {
|
|
150
|
+
"optional": true
|
|
151
|
+
},
|
|
152
|
+
"eslint-plugin-unused-imports": {
|
|
153
|
+
"optional": true
|
|
154
|
+
},
|
|
155
|
+
"globals": {
|
|
156
|
+
"optional": true
|
|
157
|
+
}
|
|
104
158
|
}
|
|
105
159
|
}
|