<app-common-dialog [dialogContent]="dialogContent" [dialogRef]="dialogRef">
  <ng-template #dialogContent>
    <form [formGroup]="changeCreditForm" (ngSubmit)="changeCredit()">
    <app-form-errors #formErrors [formGroup]="changeCreditForm"></app-form-errors>
      <div class="fl-margin-top-medium">
        <mat-radio-group
          formControlName="change_type">
          <mat-radio-button class="fl-block" [color]="'primary'" [value]="'add'" i18n>Add credit</mat-radio-button>
          <mat-radio-button class="fl-block" [color]="'primary'" [value]="'subtract'" i18n>Subtract credit</mat-radio-button>
        </mat-radio-group>
      </div>
      <div class="fl-margin-top">
        <mat-form-field *ngIf="data && data.client" appFlex="90">
          <mat-label i18n>Amount ({{data.client.currency}})</mat-label>
          <input matInput placeholder="Amount ({{data.credit.currency}})" i18n-placeholder
                 type="number" formControlName="amount" min="0.01">
          <mat-error>{{changeCreditForm.controls.amount.errors | errorFormatter}}</mat-error>
        </mat-form-field>
      </div>
    </form>
  </ng-template>
</app-common-dialog>
