<p>Create Hotel</p>

<form [formGroup]="hotelForm">
  <label for="name">Name</label>
  <div class="text-red" *ngIf="errorMessages['name']">{{ errorMessages['name'] }}</div>
  <input type="text" class="border-red-500" [class.border-8]='hotelForm.get("name")?.invalid && hotelForm.get("name")?.touched' id="name" formControlName="name">
  <label for="description">Description</label>
  <div class="text-red" *ngIf="errorMessages['description']">{{ errorMessages['description'] }}</div>
  <input type="text" class="border-red-500" [class.border-8]='hotelForm.get("description")?.invalid && hotelForm.get("description")?.touched' id="description" formControlName="description">
  <label for="imageUrl">Image</label>
  <div class="text-red" *ngIf="errorMessages['imageUrl']">{{ errorMessages['imageUrl'] }}</div>
  <input type="url" class="border-red-500" [class.border-8]='hotelForm.get("imageUel")?.invalid && hotelForm.get("imageUrl")?.touched' id="imageUrl" formControlName="imageUrl">
  <label for="price">Price</label>
  <div class="text-red" *ngIf="errorMessages['price']">{{ errorMessages['price'] }}</div>
  <input type="number" class="border-red-500" [class.border-8]='hotelForm.get("price")?.invalid' id="price" formControlName="price">
  <label for="rating">Rating</label>
  <div class="text-red" *ngIf="errorMessages['rating']">{{ errorMessages['rating'] }}</div>
  <input type="rating" class="border-red-500" [class.border-8]='hotelForm.get("rating")?.invalid' id="rating" formControlName="rating">
  <button (click)="addTag()">Add Tag</button>
  @for (tag of getTags().controls; track null) {
    <input type="tag" class="border-red-500" [class.border-8]='hotelForm.get("tag")?.invalid' id="tag" formControlName="tag">
    <button (click)="deleteTag(tag)">delete</button>
  }
  <button (click)="submit()" [disabled]="!hotelForm.valid" type="submit">Submit</button>
  <a routerLink="/">Cancel</a>
</form>
