<!--

    Copyright © 2016-2022 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section [formGroup]="parentForm">
  <mat-form-field class="mat-block">
    <mat-label translate>contact.country</mat-label>
    <mat-select formControlName="country">
      <mat-option *ngFor="let country of countries" [value]="country">
        {{ country }}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <div fxLayout.gt-sm="row" fxLayoutGap.gt-sm="10px">
    <mat-form-field class="mat-block">
      <mat-label translate>contact.city</mat-label>
      <input matInput formControlName="city">
      <mat-error *ngIf="parentForm.get('city').hasError('maxlength')">
        {{ 'contact.city-max-length' | translate }}
      </mat-error>
    </mat-form-field>
    <mat-form-field class="mat-block">
      <mat-label translate>contact.state</mat-label>
      <input matInput formControlName="state">
      <mat-error *ngIf="parentForm.get('state').hasError('maxlength')">
        {{ 'contact.state-max-length' | translate }}
      </mat-error>
    </mat-form-field>
    <mat-form-field class="mat-block">
      <mat-label translate>contact.postal-code</mat-label>
      <input matInput formControlName="zip">
      <mat-error *ngIf="parentForm.get('zip').hasError('pattern')">
        {{ 'contact.postal-code-invalid' | translate }}
      </mat-error>
    </mat-form-field>
  </div>
  <mat-form-field class="mat-block">
    <mat-label translate>contact.address</mat-label>
    <input matInput formControlName="address">
  </mat-form-field>
  <mat-form-field class="mat-block">
    <mat-label translate>contact.address2</mat-label>
    <input matInput formControlName="address2">
  </mat-form-field>
  <mat-form-field class="mat-block">
    <mat-label translate>contact.phone</mat-label>
    <input matInput formControlName="phone">
    <mat-error *ngIf="parentForm.get('phone').hasError('maxlength')">
      {{ 'contact.phone-max-length' | translate }}
    </mat-error>
  </mat-form-field>
  <mat-form-field class="mat-block">
    <mat-label translate>contact.email</mat-label>
    <input matInput formControlName="email">
    <mat-error *ngIf="parentForm.get('email').hasError('email')">
      {{ 'user.invalid-email-format' | translate }}
    </mat-error>
  </mat-form-field>
</section>
