<my-alert *ngIf="error" type="danger">{{ error }}</my-alert>
<my-alert *ngIf="success" type="success">{{ success }}</my-alert>

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

  @if (verificationEmailSent) {
    <div i18n>Email verification sent!</div>
  } @else {
    <button type="button" class="peertube-button-like-link" i18n (click)="resendVerificationEmail()">Resend your verification email</button>
  }
</div>

<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>
    </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" inputId="password" i18n-placeholder placeholder="Current password"
      [formError]="formErrors['password']" autocomplete="current-password"
    ></my-input-text>
  </div>

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