Skip to main content
se añadieron 54 caracteres en el cuerpo
Origen Enlace
Sixto Mujica
  • 306
  • 1
  • 5
  • 19
public applyCupon() {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage();
            this.discountCodeForm.resetForm; // esta linea es la que invoco desde el otro archivo
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>
public applyCupon() {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage();
            this.discountCodeForm.resetForm;
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>
public applyCupon() {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage();
            this.discountCodeForm.resetForm; // esta linea es la que invoco desde el otro archivo
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }
<form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>
se añadieron 1015 caracteres en el cuerpo
Origen Enlace
Sixto Mujica
  • 306
  • 1
  • 5
  • 19

--- ACTUALIZACION SOLUCION DE MI PARTE A MI PROBLEMA ----

public applyCupon(forma: NgForm) {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage();
            this.discountCodeForm.resetForm;
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
          

        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }

  if (forma.invalid) {
    Object.values(forma.controls).forEach( control => {
      control.markAllAsTouched();
    })
  }

}
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
      #forma
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
           
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>

--- ACTUALIZACION ----

public applyCupon(forma: NgForm) {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage(); 
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
          

        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }

  if (forma.invalid) {
    Object.values(forma.controls).forEach( control => {
      control.markAllAsTouched();
    })
  }

}
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
      #forma
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
           
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>

--- ACTUALIZACION SOLUCION DE MI PARTE A MI PROBLEMA ----

public applyCupon() {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage();
            this.discountCodeForm.resetForm;
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>
se añadieron 31 caracteres en el cuerpo
Origen Enlace
Sixto Mujica
  • 306
  • 1
  • 5
  • 19
public applyCupon(forma: NgForm) {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage(); 
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
          

        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }

  if (forma.invalid) {
    Object.values(forma.controls).forEach( control => {
      control.markAllAsTouched();
    })
  }

}
<div <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
      #forma
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
           
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          id="applyCoupon"type="submit"
          class="btnid="applyCoupon"
 btn-primary btn-aplicar"
        class="btn btn-primary (click)="applyCupon()"btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </div>form>
public applyCupon(forma: NgForm) {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage(); 
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
          

        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }

  if (forma.invalid) {
    Object.values(forma.controls).forEach( control => {
      control.markAllAsTouched();
    })
  }

}
<div
      [formGroup]="discountCodeForm.form"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
      #forma
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
           
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          (click)="applyCupon()"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </div>
public applyCupon(forma: NgForm) {
  this.isValidatingCupon = true;
  const cupons = this.discountCodeTags.map(tag => tag.code);
  const currentCupon = this.discountCodeForm.codeControl.value;
  if (!cupons.includes(currentCupon)) {
    const params = {
      coupon: this.discountCodeForm.codeControl.value
    } as IDiscountCodeRequestParams;
    this.discountCodeImplement.validateDiscountCode$(params)
      .pipe(take(1))
      .subscribe(response => {
        if (response.valid) {
            const couponInput = new Coupon ();
            couponInput.barCode = this.discountCodeForm.codeControl.value;
            couponInput.productName = this.discountCodeForm.codeControl.value;
            this.addCoupons.push(couponInput);
            this.guardarLocalStorage(); 
        } else {
          this.errorScheduleModalService.showErrorCouponModa(currentCupon);
          

        }
        this.discountCodeForm.codeControl.setValue('');
        this.isValidatingCupon = false;
      });
  } else {
    this.discountCodeForm.codeControl.setValue('');
  }

  if (forma.invalid) {
    Object.values(forma.controls).forEach( control => {
      control.markAllAsTouched();
    })
  }

}
 <form
      [formGroup]="discountCodeForm.form"
      (ngSubmit)="applyCupon()"
      [hidden]="discountCodeTags.length > 0"
      class="block_codigo_descuento"
      #forma
    >
      <div class="input_codigo_descuento">
        <fp-input-control
          [inputTitle]="''"
          [errorMessage]="''"
          [marginBottomZero]="true"
        >
          <input
            type="text"
            id="nameCupon"
            class="input"
            placeholder="Ej. 6W79H6"
            formControlName="code"
            [class.isinvalid]="!discountCodeForm.form.valid && discountCodeForm.form.touched"
           
          />
          <small class="small" *ngIf="!discountCodeForm.form.valid && discountCodeForm.form.touched">
            Código Inválido
          </small>
        </fp-input-control>
      </div>
      <div class="btn_agregar_codigo">
        <button
          type="submit"
          id="applyCoupon"
          class="btn btn-primary btn-aplicar"
          [disabled]="!discountCodeForm.form.valid || isValidatingCupon"
        >
          Agregar
        </button>
      </div>
    </form>
se añadieron 510 caracteres en el cuerpo
Origen Enlace
Sixto Mujica
  • 306
  • 1
  • 5
  • 19
Loading
Origen Enlace
Sixto Mujica
  • 306
  • 1
  • 5
  • 19
Loading