<app-common-dialog [dialogContent]="dialogContent" [dialogRef]="dialogRef">
  <ng-template #dialogContent>
    <form appFormSubmit (ngSubmit)="save()" [formGroup]="currencyForm" layoutDirection="column">
      <app-form-errors #formErrors [formGroup]="currencyForm"></app-form-errors>

      <app-autocomplete [control]="currencyForm.controls.code"
                        [placeholderSelected]="codePlaceholderSelected"
                        [placeholderUnselected]="codePlaceholderUnselected"
                        [switchMapHandler]="codeSwitchMapFn"></app-autocomplete>

      <mat-form-field *ngIf="!currencyForm.controls.is_default.value">
        <mat-label i18n>Rate</mat-label>
        <input matInput type="number" formControlName="rate">
        <mat-error>{{ currencyForm.controls.rate.errors | errorFormatter }}</mat-error>
        <mat-hint *ngIf="!currencyForm.controls.is_default.value" i18n>
          1 {{data?.defaultCurrency?.code}} = {{currencyForm.controls.rate.value}} {{currencyForm.controls.code.value}}
        </mat-hint>
      </mat-form-field>
      <div>
        <mat-checkbox class="fl-margin-bottom fl-margin-top-medium" formControlName="is_default"
                      color="primary" i18n>Is default</mat-checkbox>
        <app-icon [icon]="defaultCurrencyInfo"></app-icon>
      </div>
    </form>
  </ng-template>
</app-common-dialog>
