import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';

@Component({
  selector: 'app-signup-type',
  templateUrl: './signup-type.component.html',
  styleUrls: ['./signup-type.component.scss'],
})
export class SignupTypeComponent {
  active: number = -1;
  typeRoutingMap: { [key: number]: string } = {
    3: 'business',
    2: 'contractor',
    1: 'employee',
  };
  constructor(
    private readonly router: Router,
    private readonly route: ActivatedRoute,
    private readonly toastr: ToastrService
  ) {}

  onClickType(type: number): void {
    this.active = type;
  }

  openType(): void {
    if (this.active !== -1) {
      this.router.navigate([`./${this.typeRoutingMap[this.active]}`], {
        queryParams: { type: this.active },
        relativeTo: this.route,
      });
    } else {
      this.toastr.warning('Please Select Type !');
    }
  }
}
