import { Selector } from '@ngxs/store';
import { BranchState, BranchesStateModel } from '../state/branches.state';
import { mapToIterable } from '../../utils/app.utils';
import { BranchDTO } from '@swagger/checkout';

export class BranchSelectors {
  @Selector([BranchState])
  static getBranches(branchState: BranchesStateModel) {
    return branchState.branches;
  }

  @Selector([BranchState])
  static getBranchesIterable(branchState: BranchesStateModel): BranchDTO[] {
    return mapToIterable(branchState.branches);
  }

  @Selector([BranchState])
  static getUserBranch(branchState: BranchesStateModel): string {
    return branchState.userBranch;
  }
}
