import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
import { CommonFunctionService } from '../services/commonfunctions.service';

import { Router, ActivatedRoute } from '@angular/router';
import { first } from 'rxjs/operators';


@Component({
  selector: 'dvr-signup',
  templateUrl: './signup.component.html',
  styleUrls: ['./signup.component.css']
})
export class SignupComponent implements OnInit{
  public signupForm !: FormGroup;
    constructor(private commonservice: CommonFunctionService){
        console.log("in signup");
    }

    ngOnInit() {
      this.signupForm=new FormGroup({
        Username:new FormControl(null,Validators.required),
        Customer_Id:new FormControl(null,Validators.required),
        password:new FormControl(null,[Validators.required, Validators.maxLength(8)]),
        First_name:new FormControl(null,Validators.required),
        Last_name:new FormControl(null,Validators.required),
        Email:new FormControl(null,Validators.required),
        Mobile_number:new FormControl(null,Validators.required)

      })
      
    }
    onSubmit(from:FormGroup){
      const signup={
         login_id:from.value.Username,
         customer_id:"1",
         password:from.value.password,
         first_name:from.value.First_name,
         last_name:from.value.Last_name,
         email:from.value.Email,
         mobile_number:from.value.Mobile_number,
      }

      this.commonservice.getData(this.commonservice.projectpath + "/loginuser", signup).subscribe((response: any) => {
        console.log("response",response);
        
      });
       console.log("Username",from.value.Username);
       console.log("Customer Id",from.value.Customer_Id);
       console.log("password",from.value.password);
       console.log("First name",from.value.First_name);
       console.log("Last name",from.value.Last_name);
       console.log("Email",from.value.Email);
       console.log("Mobile number",from.value.Mobile_number);
    }

    
}
 