import { makeAutoObservable } from 'mobx';
import { RootStore } from 'stores/RootStore';

export class AntivirusResultTableUiStore {
  constructor(private readonly rootStore: RootStore) {
    makeAutoObservable(this);
  }

  get list(): any {
    return this.rootStore.antivirusResultsTableStore.list.map((x: any) => {
      return {
        ...x._listRecord._source,
        id: x._listRecord._id,
      };
    });
  }

  get getAntivirusEventsCount(): number {
    return this.rootStore.antivirusResultsTableStore.total;
  }

  fetchAntivirusEvents = (
    endpoint: number,
    page: number,
    pageSize: number,
    sorterField?: string,
  ): void => {
    this.rootStore.antivirusResultsTableStore.fetchAntivirusEvents(
      endpoint,
      page,
      pageSize,
      sorterField,
    );
  };

  postClamAVDB = async (data: FormData): Promise<void> => {
    await this.rootStore.antivirusResultsTableStore.postClamAVDB(data);
  };
}
