|
|
@ -1,5 +1,6 @@ |
|
|
|
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core"; |
|
|
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; |
|
|
|
import { MatSelectChange } from "@angular/material/select"; |
|
|
|
import { Router } from "@angular/router"; |
|
|
|
import { GENDER_LIST, SCHEDULE_APPOINTMENT } from "src/constants/constants"; |
|
|
|
import { ScheduleAppointmentService } from "../schedule-appointment/schedule-appointment.service"; |
|
|
@ -29,15 +30,42 @@ export class AddDependantsComponent implements OnInit { |
|
|
|
|
|
|
|
createNewForm(): void { |
|
|
|
this.addDependantForm = this.formBuilder.group({ |
|
|
|
nameOfDependant: ["John"], |
|
|
|
employeeRelation: ["Brother"], |
|
|
|
age: ["34"], |
|
|
|
gender: ["Male"], |
|
|
|
nameOfDependant: [''], |
|
|
|
employeeRelation: [''], |
|
|
|
age: [''], |
|
|
|
gender: [''], |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
createEnquirySubmitHandler() { |
|
|
|
if (this.counterArr.length < 6) { |
|
|
|
this.isMaxCount = false; |
|
|
|
let responeObj = this.addDependantForm.value; |
|
|
|
let isValidObj = { |
|
|
|
isValid:false, |
|
|
|
isNameValid:false, |
|
|
|
isEmployeeRelation:false, |
|
|
|
isAgeValid:false, |
|
|
|
isGenderValid:false |
|
|
|
} |
|
|
|
if(responeObj.nameOfDependant.length > 0){ |
|
|
|
isValidObj.isNameValid = true; |
|
|
|
} |
|
|
|
if(responeObj.employeeRelation.length > 0){ |
|
|
|
isValidObj.isEmployeeRelation = true; |
|
|
|
} |
|
|
|
if(responeObj.age.length > 0){ |
|
|
|
isValidObj.isAgeValid = true; |
|
|
|
} |
|
|
|
if(responeObj.gender.length > 0){ |
|
|
|
isValidObj.isGenderValid = true; |
|
|
|
} |
|
|
|
|
|
|
|
if(isValidObj.isNameValid && isValidObj.isEmployeeRelation && isValidObj.isAgeValid && isValidObj.isGenderValid){ |
|
|
|
isValidObj.isValid = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (isValidObj.isValid && this.counterArr.length < 6) { |
|
|
|
//this.createNewForm();
|
|
|
|
this.counter++; |
|
|
|
this.counterArr.push(this.counter); |
|
|
|
} else { |
|
|
@ -55,4 +83,14 @@ export class AddDependantsComponent implements OnInit { |
|
|
|
this.scheduleAppointmentService.saveAdditionalDependentDetails(responseObject); |
|
|
|
this.router.navigate([SCHEDULE_APPOINTMENT]); |
|
|
|
} |
|
|
|
|
|
|
|
selectGender(event:MatSelectChange){ |
|
|
|
let selectedData; |
|
|
|
selectedData = { |
|
|
|
value: event.value, |
|
|
|
text: event.source.triggerValue, |
|
|
|
}; |
|
|
|
//this.addDependantForm.form selectedData.value;
|
|
|
|
this.addDependantForm.get('gender')?.setValue(selectedData.value); |
|
|
|
} |
|
|
|
} |