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

export const selectOrderHisory = (state: RootState) =>
  state.licenseOrderHistory.domain.orderHistories;

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

export const seletctLimit = (state: RootState) =>
  state.licenseOrderHistory.apps.limit;

export const selectOffset = (state: RootState) =>
  state.licenseOrderHistory.apps.offset;

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

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

export const selectSelectedTask = (state: RootState) =>
  state.licenseOrderHistory.apps.LicenseOrder;

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