import { RootState } from "app/store";
import { ceil, floor } from "lodash";

export const selectTasks = (state: RootState) => state.dictation.domain.tasks;

export const selectTotal = (state: RootState) => state.dictation.domain.total;

export const seletctLimit = (state: RootState) => state.dictation.domain.limit;

export const selectOffset = (state: RootState) => state.dictation.domain.offset;

export const selectTotalPage = (state: RootState) => {
  const { limit, total } = state.dictation.domain;
  const page = ceil(total / limit);
  return page;
};

export const selectCurrentPage = (state: RootState) => {
  const { limit, offset } = state.dictation.domain;
  const page = floor(offset / limit) + 1;
  return page;
};

export const selectDisplayInfo = (state: RootState) =>
  state.dictation.apps.displayInfo;

export const selectDirection = (state: RootState) =>
  state.dictation.apps.direction;

export const selectParamName = (state: RootState) =>
  state.dictation.apps.paramName;

export const selectSelectedTask = (state: RootState) =>
  state.dictation.apps.selectedTask;

export const selectSelectedTranscriptionists = (state: RootState) =>
  state.dictation.apps.assignee.selected;

export const selectPoolTranscriptionists = (state: RootState) =>
  state.dictation.apps.assignee.pool;

export const selectIsLoading = (state: RootState) =>
  state.dictation.apps.isLoading;
