stores/calculation/validation: show notification

This commit is contained in:
Chika 2022-07-08 13:10:31 +03:00
parent 760ef0e078
commit 47fcc67677
2 changed files with 15 additions and 1 deletions

8
Elements/notification.ts Normal file
View File

@ -0,0 +1,8 @@
/* eslint-disable unicorn/prefer-export-from */
import { notification } from 'antd';
notification.config({
placement: 'bottomRight',
});
export default notification;

View File

@ -1,5 +1,7 @@
/* eslint-disable object-curly-newline */
import titles from 'Components/Calculation/config/elements-titles';
import type { Elements } from 'Components/Calculation/config/map/values';
import notification from 'Elements/notification';
import { makeAutoObservable, observable } from 'mobx';
import type RootStore from 'stores/root';
import type { ElementsErrors, Error } from './types';
@ -38,7 +40,11 @@ export default class ValidationStore {
this.elementsErrors[elementName]?.splice(errorIndex, 1, error);
}
// TODO: call notification
notification.error({
key: error.name,
message: `Ошибка в поле ${titles[elementName]}`,
description: error.text,
});
return () => this.#removeError(elementName, error.name);
};