import { RootState } from "../../../app/store";

export const selectInputValidationErrors = (state: RootState) => {
  const { numberOfCreateLicenses } = state.licenseCardIssue.apps;
  const hasErrorIncorrectNumberOfCreateLicenses =
    checkErrorIncorrectNumberOfCreateLicenses(numberOfCreateLicenses);

  return {
    hasErrorIncorrectNumberOfCreateLicenses,
  };
};
export const checkErrorIncorrectNumberOfCreateLicenses = (
  numberOfCreateLicenses: number
): boolean => {
  // 0以下の場合はエラー
  if (numberOfCreateLicenses <= 0) {
    return true;
  }

  return false;
};

export const selectNumberOfCreateLicenses = (state: RootState) =>
  state.licenseCardIssue.apps.numberOfCreateLicenses;

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