store/tables/validation: show notification

This commit is contained in:
Chika 2022-07-08 13:21:20 +03:00
parent 47fcc67677
commit 4d00d5b1d3
3 changed files with 23 additions and 3 deletions

View File

@ -21,7 +21,10 @@ export default class InsuranceTable {
constructor(rootStore: RootStore) {
this.root = rootStore;
this.validation = new Validation();
this.validation = new Validation({
err_key: 'ERR_INSURANCE_TABLE',
err_title: 'Ошибка в таблице страхования',
});
makeAutoObservable(this);
}

View File

@ -17,7 +17,10 @@ export default class PaymentsTable {
constructor(rootStore: RootStore) {
this.root = rootStore;
this.validation = new Validation();
this.validation = new Validation({
err_key: 'ERR_PAYMENTS_TABLE',
err_title: 'Ошибка в таблице платежей',
});
this.values = observable<number>([]);
this.statuses = observable<Status>([]);
makeAutoObservable(this);

View File

@ -1,10 +1,18 @@
import notification from 'Elements/notification';
import { makeAutoObservable, observable } from 'mobx';
type Params = {
err_key: string;
err_title: string;
};
export default class Validation {
params: Params;
messages = observable<string>([]);
constructor() {
constructor(params: Params) {
makeAutoObservable(this);
this.params = params;
}
getMessages() {
@ -20,6 +28,12 @@ export default class Validation {
this.messages.splice(messageIndex - 1, 1);
};
notification.error({
key: this.params.err_key,
message: this.params.err_title,
description: message,
});
return removeError;
};