<commit_before>import { PizzaService } from './../../pizza.service';
import { CustomPizza } from './../make-custom-pizza/custom-pizza.model';
import { Component, OnInit, Inject, Input, ViewContainerRef } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { MdDialogRef, MD_DIALOG_DATA } from '@angular/material';
import { AuthService } from '../../services/auth/auth.service';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';


@Component({
  selector: 'app-finalize-custom-pizza',
  templateUrl: './finalize-custom-pizza.component.html',
  styleUrls: ['./finalize-custom-pizza.component.css']
})
export class FinalizeCustomPizzaComponent implements OnInit {

  btnDisabled = false;

  constructor(public dialogRef: MdDialogRef<FinalizeCustomPizzaComponent>,
    private pizzaService: PizzaService,
    public customPizza: CustomPizza,
    public auth: AuthService,
    public toastr: ToastsManager,
    vcr: ViewContainerRef) {
    this.toastr.setRootViewContainerRef(vcr);
  }

  addToCart() {
    this.btnDisabled = true;

    this.pizzaService.getUsers()
      .map((users) => {
        const loggedUser = users.find((u) => u.authKey === localStorage.getItem('auth-key'));
        const body = {
          pizza: this.customPizza,
          userId: loggedUser.id
        };
        this.pizzaService.addToCart(body)
          .subscribe();
      })
      .subscribe(() => {
        this.btnDisabled = false;
      });

    this.toastr.options = {
      animate: 'flyRight',
      positionClass: 'toast-top-full-width',
    };
    this.toastr.success('Your list has been successfuly cleared!', null, { toastLife: 2000 });
    this.dialogRef.close();
  }
<commit_msg>create pizza validation + toastr mesages<commit_after>import { MakeCustomPizzaComponent } from './../make-custom-pizza/make-custom-pizza.component';
import { PizzaService } from './../../pizza.service';
import { CustomPizza } from './../make-custom-pizza/custom-pizza.model';
import { Component, OnInit, Inject, Input, ViewContainerRef } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { MdDialog, MdDialogRef, MD_DIALOG_DATA } from '@angular/material';
import { AuthService } from '../../services/auth/auth.service';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';


@Component({
  selector: 'app-finalize-custom-pizza',
  templateUrl: './finalize-custom-pizza.component.html',
  styleUrls: ['./finalize-custom-pizza.component.css']
})
export class FinalizeCustomPizzaComponent implements OnInit {

  btnDisabled = false;

  constructor(public dialogRef: MdDialogRef<FinalizeCustomPizzaComponent>,
    private pizzaService: PizzaService,
    public customPizza: CustomPizza,
    public auth: AuthService,
    public toastr: ToastsManager,
    private dialog: MdDialog,
    vcr: ViewContainerRef) {
    this.toastr.setRootViewContainerRef(vcr);
  }


  addToCart() {
    this.btnDisabled = true;
    const currPrice = this.customPizza.price;

    if (!isNaN(currPrice)) {
      this.pizzaService.getUsers()
        .map((users) => {
          const loggedUser = users.find((u) => u.authKey === localStorage.getItem('auth-key'));
          const body = {
            pizza: this.customPizza,
            userId: loggedUser.id
          };
          this.pizzaService.addToCart(body)
            .subscribe();
        })
        .subscribe(() => {
          this.btnDisabled = false;
        });

      this.toastr.options = {
        animate: 'flyRight',
        positionClass: 'toast-top-full-width',
        showCloseButton: 'true'
      };
      this.toastr.success('Your list has been successfuly cleared!', null, { toastLife: 2000 });
      this.dialogRef.close();
    } else {
      this.toastr.options = {
        animate: 'flyRight',
        positionClass: 'toast-top-full-width',
        showCloseButton: 'true'
      };
       this.toastr.error('You have to choose pizza size !', null, { toastLife: 4000 });
      this.toastr.error('You have to choose pizza flour and size!', null, { toastLife: 4000 });
    }
  }

{'fraction_non_alphanumeric': 0.1392839627268269, 'fraction_numerical': 0.004904364884747425, 'mean_word_length': 3.1202020202020204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '419948', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1237, 'n_words': 251}