From e541a155ffda9c388f25a29a49f64c86990c8451 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Mon, 9 Aug 2021 11:35:32 +0300 Subject: [PATCH] Refactor create account component onInit function. --- .../create-account.component.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/app/pages/accounts/create-account/create-account.component.ts b/src/app/pages/accounts/create-account/create-account.component.ts index c29d714..bbdec1c 100644 --- a/src/app/pages/accounts/create-account/create-account.component.ts +++ b/src/app/pages/accounts/create-account/create-account.component.ts @@ -38,6 +38,22 @@ export class CreateAccountComponent implements OnInit { referrer: ['', Validators.required], businessCategory: ['', Validators.required], }); + this.loadSearchData(); + } + + get createFormStub(): any { + return this.createForm.controls; + } + + onSubmit(): void { + this.submitted = true; + if (this.createForm.invalid || !confirm('Create account?')) { + return; + } + this.submitted = false; + } + + loadSearchData(): void { this.userService.getCategories(); this.userService.categoriesSubject.subscribe((res) => { this.categories = Object.keys(res); @@ -55,16 +71,4 @@ export class CreateAccountComponent implements OnInit { .pipe(first()) .subscribe((res) => (this.genders = res)); } - - get createFormStub(): any { - return this.createForm.controls; - } - - onSubmit(): void { - this.submitted = true; - if (this.createForm.invalid || !confirm('Create account?')) { - return; - } - this.submitted = false; - } }