<commit_before>import { Component, ViewChild } from '@angular/core';
import { PasswordToggleComponent } from 'app/shared/components/password-toggle/password-toggle.component';
import { NgForm } from '@angular/forms';
import { MdSnackBar } from '@angular/material';
import { AuthService } from 'app/shared/services/auth.service';
import { Email } from "types/email";
import { PostalCode } from "types/postalcode";
import { Phone } from "types/phone";

@Component({
  selector: 'register',
  templateUrl: './register.component.html',
  styleUrls: ['../child.component.scss']
})
export class RegisterComponent {
  @ViewChild(PasswordToggleComponent)
  toggler: PasswordToggleComponent;

  @ViewChild(NgForm)
  form: NgForm;

  name: string;
  email: string;
  password: <PASSWORD>;
  postalcode: string;
  phone: string;

  errors: { [input: string]: string };

  private service: AuthService;
  private snackbar: MdSnackBar;

  constructor(service: AuthService, snackbar: MdSnackBar) {
    this.service = service;
    this.snackbar = snackbar;
    this.errors = {};
  }

  register(): void {
    if (!this.validate()) return;

    let email = new Email(this.email);
    let postalcode = new PostalCode(this.postalcode);
    let phone = new Phone(this.phone);

    let self = this;
    this.service.register(this.name, email, this.password, postalcode, phone).then(function registered() {
      self.reset();
      self.snackbar.open('Successfully registered! Please confirm your email', undefined, {
        duration: 2000
      });
    }, function error(error) {
      self.snackbar.open(error.message, undefined, {
        duration: 2000
      });
    });
  }

  private validate(): boolean {
    this.errors = {};
    let name = this.name !== '';
    let email = Email.validate(this.email);
    let password = this.password.length > 6;
    let postalcode = PostalCode.validate(this.postalcode);
    let phone = Phone.validate(this.phone);

    if (!email) {
      this.errors['email'] = 'Invalid format';
    }

    if (!password) {
      this.errors['password'] = 'Must have at least 6 characters';
    }<commit_msg>feat(register): add the loading control<commit_after>import { Component, ViewChild } from '@angular/core';
import { PasswordToggleComponent } from 'app/shared/components/password-toggle/password-toggle.component';
import { NgForm } from '@angular/forms';
import { MdSnackBar } from '@angular/material';
import { AuthService } from 'app/shared/services/auth.service';
import { Email } from "types/email";
import { PostalCode } from "types/postalcode";
import { Phone } from "types/phone";
import { LoaderService } from 'app/shared/services/loader.service';

@Component({
  selector: 'register',
  templateUrl: './register.component.html',
  styleUrls: ['../child.component.scss']
})
export class RegisterComponent {
  @ViewChild(PasswordToggleComponent)
  toggler: PasswordToggleComponent;

  @ViewChild(NgForm)
  form: NgForm;

  name: string;
  email: string;
  password: string;
  postalcode: string;
  phone: string;

  errors: { [input: string]: string };

  private service: AuthService;
  private snackbar: MdSnackBar;
  private loader: LoaderService;

  constructor(service: AuthService, snackbar: MdSnackBar, loaderService: LoaderService) {
    this.service = service;
    this.snackbar = snackbar;
    this.loader = loaderService;

    this.errors = {};
  }

  register(): void {
    if (!this.validate()) return;

    this.loader.update(true);

    let email = new Email(this.email);
    let postalcode = new PostalCode(this.postalcode);
    let phone = new Phone(this.phone);

    let self = this;
    this.service.register(this.name, email, this.password, postalcode, phone).then(function registered() {
      self.loader.update(false);

      self.reset();
      self.snackbar.open('Successfully registered! Please confirm your email', undefined, {
        duration: 2000
      });
    }, function error(error) {
      self.loader.update(false);

      self.snackbar.open(error.message, undefined, {
        duration: 2000
      });
    });
  }

  private validate(): boolean {
    this.errors = {};
    let name = this.name !== '';
    let email = Email.validate(this.email);
    let password = this.password.length > 6;
    let postalcode = PostalCode.validate(this.postalcode);
    let phone = Phone.validate(this.phone);

    if (!email) {
      this.errors['email'] = 'Invalid format';
    }

    if (!password) {
      this.errors['password'] = 'Must <PASSWORD> at least <PASSWORD>';
    }
{'fraction_non_alphanumeric': 0.136986301369863, 'fraction_numerical': 0.0041979673000441895, 'mean_word_length': 3.628834355828221, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '1075974', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1322, 'n_words': 325}