import { Dealer, User } from "api/api";
import { RootState } from "app/store";

export const selectAccountInfo = (state: RootState) =>
  state.account.domain.getAccountInfo;
export const selectAllDealers = (state: RootState) =>
  state.account.domain.dealers;
export const selectDealers = (state: RootState) => {
  const { dealers } = state.account.domain;
  const { country } = state.account.domain.getAccountInfo.account;
  return dealers.filter((x: Dealer) => x.country === country);
};
export const selectUsers = (state: RootState) =>
  state.account.domain.users.filter((x: User) => x.emailVerified);
export const selectIsLoading = (state: RootState) =>
  state.account.apps.isLoading;
export const selectUpdateAccountInfo = (state: RootState) =>
  state.account.apps.updateAccountInfo;
