<h2 mat-dialog-title>Automatischen Versand einrichten</h2>
<mat-dialog-content>
  @if (loadError()) {
    <p class="error-message" role="alert">{{ loadError() }}</p>
  }
  @if (saveError()) {
    <p class="error-message" role="alert">{{ saveError() }}</p>
  }
  <mat-form-field appearance="outline">
    <mat-label>E-Mail-Adresse hinzufügen</mat-label>
    <input matInput #recipientInput (keydown.enter)="addRecipient(recipientInput.value); recipientInput.value = ''" />
  </mat-form-field>
  <mat-chip-set>
    @for (recipient of recipients(); track recipient) {
      <mat-chip (removed)="removeRecipient(recipient)">
        {{ recipient }}
        <button matChipRemove><mat-icon>cancel</mat-icon></button>
      </mat-chip>
    }
  </mat-chip-set>
  <form [formGroup]="form">
    <mat-form-field appearance="outline">
      <mat-label>Intervall</mat-label>
      <mat-select formControlName="interval">
        <mat-option value="monthly">Monatlich</mat-option>
        <mat-option value="quarterly">Quartalsweise</mat-option>
        <mat-option value="yearly">Jährlich</mat-option>
      </mat-select>
    </mat-form-field>
    <mat-slide-toggle formControlName="active">Aktiv</mat-slide-toggle>
  </form>
</mat-dialog-content>
<mat-dialog-actions align="end">
  <button mat-button type="button" (click)="dialogRef.close()">Abbrechen</button>
  <button mat-flat-button type="button" (click)="save()">Speichern</button>
</mat-dialog-actions>
