<ng-template #modal>
  <div class="modal-header">
    <h4 i18n class="modal-title">
      <ng-container *ngIf="isAccept()">Accept {{ registration.username }} registration</ng-container>
      <ng-container *ngIf="isReject()">Reject {{ registration.username }} registration</ng-container>
    </h4>

    <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
  </div>

  <form novalidate [formGroup]="form" (ngSubmit)="processRegistration()">
    <div class="modal-body mb-3">

      <div i18n *ngIf="!registration.emailVerified" class="alert alert-warning">
        Registration email has not been verified. Email delivery has been disabled by default.
      </div>

      <div class="description">
        <ng-container *ngIf="isAccept()">
          <p i18n>
            <strong>Accepting</strong>&nbsp;<em>{{ registration.username }}</em> registration will create the account and channel.
          </p>

          <p *ngIf="isEmailEnabled()" i18n [ngClass]="{ 'text-decoration-line-through': isPreventEmailDeliveryChecked() }">
            An email will be sent to <em>{{ registration.email }}</em> explaining its account has been created with the moderation response you'll write below.
          </p>

          <div *ngIf="!isEmailEnabled()" class="alert alert-warning" i18n>
            Emails are not enabled on this instance so PeerTube won't be able to send an email to <em>{{ registration.email }}</em> explaining its account has been created.
          </div>
        </ng-container>

        <ng-container *ngIf="isReject()">
          <p i18n [ngClass]="{ 'text-decoration-line-through': isPreventEmailDeliveryChecked() }">
            An email will be sent to <em>{{ registration.email }}</em> explaining its registration request has been <strong>rejected</strong> with the moderation response you'll write below.
          </p>

          <div *ngIf="!isEmailEnabled()" class="alert alert-warning" i18n>
            Emails are not enabled on this instance so PeerTube won't be able to send an email to <em>{{ registration.email }}</em> explaining its registration request has been rejected.
          </div>
        </ng-container>
      </div>

      <div class="form-group">
        <label for="moderationResponse" i18n>Send a message to the user</label>

        <textarea
          formControlName="moderationResponse" ngbAutofocus name="moderationResponse" id="moderationResponse"
          [ngClass]="{ 'input-error': formErrors['moderationResponse'] }" class="form-control"
        ></textarea>

        <div *ngIf="formErrors.moderationResponse" class="form-error">
          {{ formErrors.moderationResponse }}
        </div>
      </div>

      <div class="form-group">
        <my-peertube-checkbox
          inputName="preventEmailDelivery" formControlName="preventEmailDelivery" [disabled]="!isEmailEnabled()"
          i18n-labelText labelText="Prevent email from being sent to the user"
        ></my-peertube-checkbox>
      </div>
    </div>

    <div class="modal-footer inputs">
      <input
        type="button" role="button" i18n-value value="Cancel" class="peertube-button grey-button"
        (click)="hide()" (key.enter)="hide()"
      >

      <input type="submit" [value]="getSubmitValue()" class="peertube-button orange-button" [disabled]="!form.valid">
    </div>
  </form>
</ng-template>
