<ng-template #modal>
  <div class="modal-header">
    <h1 i18n class="modal-title">Contact the administrator(s)<p class="modal-subtitle">{{ instanceName }}</p></h1>
    <my-global-icon iconName="cross" aria-label="Close" tabindex="0" role="button" (click)="hide()" (keydown.enter)="hide()"></my-global-icon>
  </div>

  <div class="modal-body">

    <form *ngIf="isContactFormEnabled()" novalidate [formGroup]="form" (ngSubmit)="sendForm()">
      <div class="form-group">
        <label i18n for="fromName">Your name</label>
        <input
          type="text" id="fromName" class="form-control"
          formControlName="fromName" [ngClass]="{ 'input-error': formErrors.fromName }"
        >
        <div *ngIf="formErrors.fromName" class="form-error">{{ formErrors.fromName }}</div>
      </div>

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

      <div class="form-group">
        <label i18n for="subject">Subject</label>
        <input
          type="text" id="subject" class="form-control"
          formControlName="subject" [ngClass]="{ 'input-error': formErrors['subject'] }"
        >
        <div *ngIf="formErrors.subject" class="form-error">{{ formErrors.subject }}</div>
      </div>

      <div class="form-group">
        <label i18n for="body">Your message</label>
        <textarea id="body" formControlName="body" class="form-control" [ngClass]="{ 'input-error': formErrors['body'] }">
        </textarea>
        <div *ngIf="formErrors.body" class="form-error">{{ formErrors.body }}</div>
      </div>

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

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

        <input type="submit" i18n-value value="Submit" class="peertube-button orange-button" [disabled]="!form.valid" />
      </div>
    </form>

    <div *ngIf="!isContactFormEnabled()" class="alert alert-danger" i18n>The contact form is not enabled on this instance.</div>

  </div>
</ng-template>
