// Apps
import { makeAutoObservable, toJS } from 'mobx';

// Types
import { EndpointDevice } from 'myApi';
import { RootStore } from 'stores/RootStore';
import { TypeEndpointDynamicTablePath } from '../types';

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

  // Список путей антивирусного сканирования
  antivirusTablePath: TypeEndpointDynamicTablePath = [];

  // Список путей белого листа анивируса
  whiteListTablePath: TypeEndpointDynamicTablePath = [];

  // Список путей Директории сканирования при запуске
  integrityControlTablePath: TypeEndpointDynamicTablePath = [];

  get getEndpointById(): EndpointDevice | null {
    return toJS(this.rootStore.endpointStore.endpoint);
  }

  get getAntivirusTablePath(): TypeEndpointDynamicTablePath {
    return toJS(this.antivirusTablePath);
  }

  get getWhiteListTablePathTablePath(): TypeEndpointDynamicTablePath {
    return toJS(this.whiteListTablePath);
  }

  get getIntegrityControlTablePath(): TypeEndpointDynamicTablePath {
    return toJS(this.integrityControlTablePath);
  }

  setAntivirusTablePath = (value: TypeEndpointDynamicTablePath): void => {
    this.antivirusTablePath = value;
  };

  setWhiteListTablePathTablePath = (
    value: TypeEndpointDynamicTablePath,
  ): void => {
    this.whiteListTablePath = value;
  };

  setIntegrityControlTablePath = (
    value: TypeEndpointDynamicTablePath,
  ): void => {
    this.integrityControlTablePath = value;
  };

  clearTablePath = (): void => {
    this.antivirusTablePath = [];
    this.whiteListTablePath = [];
    this.integrityControlTablePath = [];
  };
}
