store/tables/validation: show notification
This commit is contained in:
parent
47fcc67677
commit
4d00d5b1d3
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user