<form nz-form [formGroup]="form" (ngSubmit)="submit()" role="form">
  <nz-tabset [nzAnimated]="false" class="tabs" (nzSelectChange)="switch($event)">
    <nz-tab [nzTitle]="'app.login.tab-login-credentials' | translate">
      <nz-alert *ngIf="error" [nzType]="'error'" [nzMessage]="error" [nzShowIcon]="true" class="mb-lg"></nz-alert>
      <nz-form-item>
        <nz-form-control>
          <nz-input-group nzSize="large" nzPrefixIcon="anticon anticon-user">
            <input nz-input formControlName="userName" placeholder="username: admin or user">
          </nz-input-group>
          <nz-form-explain *ngIf="userName.dirty && userName.errors">
            {{ 'Please enter mobile number!' | translate }}
          </nz-form-explain>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-control>
          <nz-input-group nzSize="large" nzPrefixIcon="anticon anticon-lock">
            <input nz-input type="password" formControlName="password" placeholder="password: ng-alain.com">
          </nz-input-group>
          <nz-form-explain *ngIf="password.dirty && password.errors">
            {{ 'Please enter password!' | translate }}
          </nz-form-explain>
        </nz-form-control>
      </nz-form-item>
    </nz-tab>
    <nz-tab [nzTitle]="'app.login.tab-login-mobile' | translate">
      <nz-form-item>
        <nz-form-control>
          <nz-input-group nzSize="large" nzPrefixIcon="anticon anticon-user">
            <input nz-input formControlName="mobile" placeholder="mobile number">
          </nz-input-group>
          <nz-form-explain *ngIf="mobile.dirty && mobile.errors">
            <ng-container *ngIf="mobile.errors.required">
              {{ 'validation.phone-number.required' | translate }}
            </ng-container>
            <ng-container *ngIf="mobile.errors.pattern">
              {{ 'validation.phone-number.wrong-format' | translate }}
            </ng-container>
          </nz-form-explain>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-control>
          <nz-row [nzGutter]="8">
            <nz-col [nzSpan]="16">
              <nz-input-group nzSize="large" nzPrefixIcon="anticon anticon-mail">
                <input nz-input formControlName="captcha" placeholder="captcha">
              </nz-input-group>
              <nz-form-explain *ngIf="captcha.dirty && captcha.errors">
                {{ 'validation.verification-code.required' | translate }}
              </nz-form-explain>
            </nz-col>
            <nz-col [nzSpan]="8">
              <button type="button" nz-button nzSize="large" (click)="getCaptcha()" [disabled]="count" nzBlock [nzLoading]="http.loading">
                {{ count ? count + 's' : 'app.register.get-verification-code' | translate }}
              </button>
            </nz-col>
          </nz-row>
        </nz-form-control>
      </nz-form-item>
    </nz-tab>
  </nz-tabset>
  <nz-form-item>
    <nz-col [nzSpan]="12">
      <label nz-checkbox formControlName="remember">{{ 'app.login.remember-me' | translate }}</label>
    </nz-col>
    <nz-col [nzSpan]="12" class="text-right">
      <a class="forgot" (click)="msg.error('请找欧阳锋')">{{ 'app.login.forgot-password' | translate }}</a>
    </nz-col>
  </nz-form-item>
  <nz-form-item>
    <button nz-button type="submit" nzType="primary" nzSize="large" [nzLoading]="http.loading" nzBlock>
      {{ 'app.login.login' | translate }}
    </button>
  </nz-form-item>
</form>
<div class="other">
  {{ 'app.login.sign-in-with' | translate }}
  <i nz-tooltip="in fact Auth0 via window" (click)="open('auth0', 'window')" nz-icon type="alipay-circle" class="icon"></i>
  <i nz-tooltip="in fact Github via redirect" (click)="open('github')" nz-icon type="taobao-circle" class="icon"></i>
  <i (click)="open('weibo', 'window')" nz-icon type="weibo-circle" class="icon"></i>
  <a class="register" routerLink="/passport/register">{{ 'app.login.signup' | translate }}</a>
</div>
