update view profile unit tests

This commit is contained in:
Denys Vuika
2023-02-14 12:48:17 -05:00
committed by Sheena Malhotra
parent 62ad3cd786
commit 7c89b53928
4 changed files with 96 additions and 70 deletions

View File

@@ -43,24 +43,17 @@ export class ViewProfileComponent implements OnInit {
ngOnInit() {
this.peopleApi
.getPerson('-me-')
.then((userInfo) => {
this.personDetails = userInfo?.entry;
this.populateForm(userInfo?.entry);
})
.catch((error) => {
throwError(error);
});
.then((userInfo) => this.populateForm(userInfo?.entry))
.catch((error) => throwError(error));
}
populateForm(userInfo: Person) {
this.personDetails = userInfo;
this.profileForm = new FormGroup({
jobTitle: new FormControl(userInfo?.jobTitle || ''),
location: new FormControl(userInfo?.location || ''),
telephone: new FormControl(userInfo?.telephone || '', [Validators.pattern('^([0-9]+-)*[0-9]+$')]),
mobile: new FormControl(userInfo?.mobile || '', [Validators.pattern('^([0-9]+-)*[0-9]+$')]),
oldPassword: new FormControl(''),
newPassword: new FormControl(''),
verifyPassword: new FormControl(''),
companyName: new FormControl(userInfo?.company?.organization || ''),
companyPostCode: new FormControl(userInfo?.company?.postcode || ''),
companyAddress: new FormControl(userInfo?.company?.address1 || ''),