<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
<div *ngIf="success" class="alert alert-success">{{ success }}</div>

<div i18n class="pending-email" *ngIf="user.pendingEmail">
  <strong>{{ user.pendingEmail }}</strong> is awaiting email verification
</div>

<form role="form" class="change-email" (ngSubmit)="changeEmail()" [formGroup]="form">

  <div class="form-group">
    <label i18n for="new-email">Change your email</label>

    <div i18n class="form-group-description">
      Your current email is <strong>{{ user.email }}</strong>.
      It is never shown to the public.
    </div>

    <input
      type="email" id="new-email" i18n-placeholder placeholder="New email" class="form-control"
      formControlName="new-email" [ngClass]="{ 'input-error': formErrors['new-email'] }"
    >
    <div *ngIf="formErrors['new-email']" class="form-error" role="alert">
      {{ formErrors['new-email'] }}
    </div>
  </div>

  <div class="form-group">
    <my-input-text
      formControlName="password" id="password" i18n-placeholder placeholder="Current password"
      [formError]="formErrors['password']" autocomplete="current-password"
    ></my-input-text>
  </div>

  <input type="submit" i18n-value value="Change email" [disabled]="!form.valid">
</form>
