@qlibs/utils 1.7.1 → 1.7.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.
@@ -1,4 +1,4 @@
1
1
  export declare const onFinishFailed: (antdErrorInfo: any, config: {
2
- showErrorOnToast?: string[];
3
- toastFunction?: any;
2
+ form: any;
3
+ toastFunction: any;
4
4
  }) => void;
@@ -4,19 +4,20 @@ exports.onFinishFailed = void 0;
4
4
  const onFinishFailed = (antdErrorInfo, config) => {
5
5
  console.error('antdErrorInfo', antdErrorInfo);
6
6
  const { errorFields } = antdErrorInfo;
7
- if (config.showErrorOnToast) {
8
- for (const errorField of errorFields) {
9
- if (config.showErrorOnToast.includes(errorField.name.join('.')) && (config === null || config === void 0 ? void 0 : config.toastFunction)) {
10
- config.toastFunction.error(errorField.errors.join(' '));
11
- }
7
+ if (errorFields && errorFields.length > 0) {
8
+ const firstError = errorFields[0];
9
+ if (firstError.errors && firstError.errors.length > 0) {
10
+ config.toastFunction.error(firstError.errors.join(' '));
12
11
  }
12
+ setTimeout(() => {
13
+ config.form.scrollToField(firstError.name, {
14
+ behavior: 'smooth',
15
+ block: 'center',
16
+ });
17
+ }, 100);
13
18
  }
14
19
  else {
15
- for (const errorField of errorFields) {
16
- if (config === null || config === void 0 ? void 0 : config.toastFunction) {
17
- config.toastFunction.error(errorField.errors.join(' '));
18
- }
19
- }
20
+ config.toastFunction.error('Something wrong. Please check your inputs.');
20
21
  }
21
22
  };
22
23
  exports.onFinishFailed = onFinishFailed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlibs/utils",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "",
5
5
  "author": "QBIT Developer",
6
6
  "license": "MIT",