|
@@ -10,6 +10,7 @@ import { ComponentBase } from '@core/base/common-base';
|
|
import { AuthService } from '@core/services/authentication/auth.service';
|
|
import { AuthService } from '@core/services/authentication/auth.service';
|
|
|
|
|
|
import {
|
|
import {
|
|
|
|
+ CITY,
|
|
COUNTRY,
|
|
COUNTRY,
|
|
INDUSTRY,
|
|
INDUSTRY,
|
|
JOB_TITLE,
|
|
JOB_TITLE,
|
|
@@ -17,7 +18,9 @@ import {
|
|
UNIVERISTY,
|
|
UNIVERISTY,
|
|
} from '@core/models/authenticcation.model';
|
|
} from '@core/models/authenticcation.model';
|
|
import { takeUntil } from 'rxjs';
|
|
import { takeUntil } from 'rxjs';
|
|
-import { ActivatedRoute, Params } from '@angular/router';
|
|
|
|
|
|
+import { ActivatedRoute, Params, Router } from '@angular/router';
|
|
|
|
+import { ToastrService } from 'ngx-toastr';
|
|
|
|
+import { SharedService } from '../../../core/services/shared.service';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-signup-contractor',
|
|
selector: 'app-signup-contractor',
|
|
@@ -29,15 +32,19 @@ export class SignupContractorComponent
|
|
implements OnInit, BaseForm
|
|
implements OnInit, BaseForm
|
|
{
|
|
{
|
|
form!: FormGroup;
|
|
form!: FormGroup;
|
|
- multiPartForm = new FormData();
|
|
|
|
jobTitles: JOB_TITLE[] = [];
|
|
jobTitles: JOB_TITLE[] = [];
|
|
qualificationList: QUALIFICATION[] = [];
|
|
qualificationList: QUALIFICATION[] = [];
|
|
univerisites: UNIVERISTY[] = [];
|
|
univerisites: UNIVERISTY[] = [];
|
|
countries: COUNTRY[] = [];
|
|
countries: COUNTRY[] = [];
|
|
industriesList: INDUSTRY[] = [];
|
|
industriesList: INDUSTRY[] = [];
|
|
|
|
+ cities: CITY[] = [];
|
|
|
|
+
|
|
constructor(
|
|
constructor(
|
|
private readonly authService: AuthService,
|
|
private readonly authService: AuthService,
|
|
- private readonly route: ActivatedRoute
|
|
|
|
|
|
+ private readonly route: ActivatedRoute,
|
|
|
|
+ private readonly toastr: ToastrService,
|
|
|
|
+ private readonly sharedService: SharedService,
|
|
|
|
+ private readonly router: Router
|
|
) {
|
|
) {
|
|
super();
|
|
super();
|
|
}
|
|
}
|
|
@@ -71,8 +78,15 @@ export class SignupContractorComponent
|
|
phoneNumber: new UntypedFormControl(null, [Validators.required]),
|
|
phoneNumber: new UntypedFormControl(null, [Validators.required]),
|
|
userType: new UntypedFormControl(null, [Validators.required]),
|
|
userType: new UntypedFormControl(null, [Validators.required]),
|
|
linkedInLink: new UntypedFormControl(null, [Validators.required]),
|
|
linkedInLink: new UntypedFormControl(null, [Validators.required]),
|
|
- userName: new UntypedFormControl(null, [Validators.required]),
|
|
|
|
- password: new UntypedFormControl(null, [Validators.required]),
|
|
|
|
|
|
+ userName: new UntypedFormControl(null, [
|
|
|
|
+ Validators.required,
|
|
|
|
+ Validators.minLength(6),
|
|
|
|
+ ]),
|
|
|
|
+ password: new UntypedFormControl(null, [
|
|
|
|
+ Validators.required,
|
|
|
|
+ Validators.pattern(this.sharedService.StrongPasswordRegx),
|
|
|
|
+ Validators.minLength(8),
|
|
|
|
+ ]),
|
|
favoriteName: new UntypedFormControl(null, [Validators.required]),
|
|
favoriteName: new UntypedFormControl(null, [Validators.required]),
|
|
passportNumber: new UntypedFormControl(null, [Validators.required]),
|
|
passportNumber: new UntypedFormControl(null, [Validators.required]),
|
|
qualificationId: new UntypedFormControl(null, [Validators.required]),
|
|
qualificationId: new UntypedFormControl(null, [Validators.required]),
|
|
@@ -81,6 +95,11 @@ export class SignupContractorComponent
|
|
industryId: new UntypedFormControl(null, [Validators.required]),
|
|
industryId: new UntypedFormControl(null, [Validators.required]),
|
|
taxNumber: new UntypedFormControl(null, [Validators.required]),
|
|
taxNumber: new UntypedFormControl(null, [Validators.required]),
|
|
incomeTaxValue: new UntypedFormControl(null, Validators.required),
|
|
incomeTaxValue: new UntypedFormControl(null, Validators.required),
|
|
|
|
+ cvAttach: new UntypedFormControl(null),
|
|
|
|
+ passportAttach: new UntypedFormControl(null),
|
|
|
|
+ eduCertificateAttach: new UntypedFormControl(null),
|
|
|
|
+ experienceCertificateAttach: new UntypedFormControl(null),
|
|
|
|
+ profCertificateAttach: new UntypedFormControl(null),
|
|
userAddress: new UntypedFormGroup({
|
|
userAddress: new UntypedFormGroup({
|
|
countryId: new UntypedFormControl(null, [Validators.required]),
|
|
countryId: new UntypedFormControl(null, [Validators.required]),
|
|
cityId: new UntypedFormControl(null, [Validators.required]),
|
|
cityId: new UntypedFormControl(null, [Validators.required]),
|
|
@@ -137,39 +156,39 @@ export class SignupContractorComponent
|
|
|
|
|
|
onUploadFile(event: any): void {
|
|
onUploadFile(event: any): void {
|
|
if (event.file) {
|
|
if (event.file) {
|
|
- this.multiPartForm.append(event.type, event.file);
|
|
|
|
|
|
+ this.form.patchValue({ [event.type]: event.file });
|
|
} else {
|
|
} else {
|
|
- this.multiPartForm.delete(event.type);
|
|
|
|
|
|
+ this.form.patchValue({ [event.type]: null });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- onSubmit(): void {
|
|
|
|
- for (const key in this.form.value) {
|
|
|
|
- if (this.form.value.hasOwnProperty(key)) {
|
|
|
|
- this.multiPartForm.append(key, this.form.value[key]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ onChangeCountry(event: any): void {
|
|
|
|
+ this.authService
|
|
|
|
+ .getCities({ CountryId: event.target.value })
|
|
|
|
+ .subscribe((res) => {
|
|
|
|
+ this.cities = res;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
- // this.multiPartForm.append(
|
|
|
|
- // 'userAddress',
|
|
|
|
- // JSON.stringify({
|
|
|
|
- // countryId: this.form.get('countryId')?.value,
|
|
|
|
- // cityId: 1,
|
|
|
|
- // postalCode: this.form.get('postalCode')?.value,
|
|
|
|
- // addressDesc: this.form.get('addressDesc')?.value,
|
|
|
|
- // })
|
|
|
|
- // );
|
|
|
|
|
|
+ onSubmit(): void {
|
|
|
|
+ this.router.navigate(['/auth']);
|
|
|
|
|
|
- this.authService
|
|
|
|
- .addEmployee(this.multiPartForm)
|
|
|
|
- .pipe(takeUntil(this.destroy$))
|
|
|
|
- .subscribe(
|
|
|
|
- (res) => {
|
|
|
|
- console.log(res);
|
|
|
|
- },
|
|
|
|
- (err) => {
|
|
|
|
- console.log(err);
|
|
|
|
|
|
+ const multiPartForm = new FormData();
|
|
|
|
+ if (this.submitValidity(this.form)) {
|
|
|
|
+ for (const key in { ...this.form.value }) {
|
|
|
|
+ if (this.form.value.hasOwnProperty(key)) {
|
|
|
|
+ if (this.form.get(key)?.value) {
|
|
|
|
+ multiPartForm.append(key, this.form.get(key)?.value);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- );
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.authService
|
|
|
|
+ .addEmployee(multiPartForm)
|
|
|
|
+ .pipe(takeUntil(this.destroy$))
|
|
|
|
+ .subscribe((res) => {
|
|
|
|
+ this.toastr.success('Registeration Successfully !');
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|