import { Pipe, PipeTransform } from '@angular/core';
import { Pricing } from '../models/pricing.model';

@Pipe({
  name: 'pricingSessionsWeeklyText'
})
export class PricingSessionsWeeklyTextPipe implements PipeTransform {

  transform(p:Pricing): string {
    let res:string = "";
    const sum:number = p.wod_counter + p.open_counter + p.total_counter;

    if(p.recharge_weekly) {
      //no es bono
      if(p.wod_counter==null && p.open_counter==null && p.total_counter) {
        res = "Sesiones ilimitadas";
      }
      else if(sum > 99) {
        res = "";
      }
      else {
        res = `${sum} sesiones semanales`;
      }
    }
    else {
      //es bono
      res = `${sum} sesiones`;
    }

    return res;
  }

}
