{"size": 1092, "ext": "js", "max_stars_repo_path": "packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/orderAlias/numberChoice/number-choice.controller.js", "max_stars_repo_name": "kseckinc/manager", "max_stars_repo_stars_event_min_datetime": "2018-10-30T09:45:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-14T12:43:02.000Z", "max_issues_repo_path": "packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/orderAlias/numberChoice/number-choice.controller.js", "max_issues_repo_name": "kseckinc/manager", "max_issues_repo_issues_event_min_datetime": "2018-11-15T20:18:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-18T11:40:15.000Z", "max_forks_repo_path": "packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/orderAlias/numberChoice/number-choice.controller.js", "max_forks_repo_name": "kseckinc/manager", "max_forks_repo_forks_event_min_datetime": "2019-01-16T19:12:57.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-07T18:29:46.000Z"}
{"max_stars_count": 14, "max_issues_count": 289, "max_forks_count": 10, "avg_line_length": 28.0, "max_line_length": 67, "alphanum_fraction": 0.6611721612}
export default class NumberChoiceController {
  $onInit() {
    this.hasPremium = this.choices.premium?.length;
    this.commonChoices = this.choices.common.map((choice) => ({
      id: choice,
      name: choice,
    }));

    if (this.hasPremium) {
      this.premiumChoices = this.choices.premium.map((choice) => ({
        id: choice,
        name: choice,
      }));
    }

    if (this.ngModel.numberType === this.prices.common.range) {
      [this.selectedCommonNumber] = this.commonChoices;
      this.ngModel.premium = undefined;
    } else {
      [this.selectedPremiumNumber] = this.premiumChoices;
      this.ngModel.common = undefined;
    }
  }

  onCommonChange(modelValue) {
    this.ngModel.numberType = this.prices.common.range;
    this.ngModel.common = modelValue.id;
    this.ngModel.premium = undefined;
    this.selectedPremiumNumber = undefined;
  }

  onPremiumChange(modelValue) {
    this.ngModel.numberType = this.prices.premium.range;
    this.ngModel.premium = modelValue.id;
    this.ngModel.common = undefined;
    this.selectedCommonNumber = undefined;
  }
}
