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

<div i18n class="current-email">
  Your current email is <span class="email">{{ user.email }}</span>
</div>

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

<form role="form" class="change-email" (ngSubmit)="changeEmail()" [formGroup]="form" *ngIf="user.pluginAuth === null">

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

  <div class="form-group">
    <label i18n for="new-email">Your current password</label>
    <input
      type="password" id="password" i18n-placeholder placeholder="Your password" autocomplete="off"
      formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }" class="form-control"
    >
    <div *ngIf="formErrors['password']" class="form-error">
      {{ formErrors['password'] }}
    </div>
  </div>

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