35 lines
872 B
TypeScript
35 lines
872 B
TypeScript
import type { Payment } from 'Components/Output/PaymentsTable/types';
|
|
import type { IObservableArray } from 'mobx';
|
|
import { makeAutoObservable, observable } from 'mobx';
|
|
|
|
import type RootStore from 'stores/root';
|
|
import { defaultResultsValues } from './default-values';
|
|
import type { ResultsValues } from './types';
|
|
|
|
export default class Results {
|
|
root: RootStore;
|
|
payments: IObservableArray<Payment>;
|
|
values: ResultsValues;
|
|
|
|
constructor(rootStore: RootStore) {
|
|
this.payments = observable<Payment>([]);
|
|
this.values = defaultResultsValues;
|
|
makeAutoObservable(this);
|
|
|
|
this.root = rootStore;
|
|
}
|
|
|
|
setPayments = (payments: Payment[]) => {
|
|
this.payments.replace(payments);
|
|
};
|
|
|
|
setValues = (values: ResultsValues) => {
|
|
this.values = values;
|
|
};
|
|
|
|
clear = () => {
|
|
this.payments.clear();
|
|
this.values = defaultResultsValues;
|
|
};
|
|
}
|