diff --git a/src/app/hotel-list/hotel-list.component.ts b/src/app/hotel-list/hotel-list.component.ts
index 528c8ce..6da0006 100644
--- a/src/app/hotel-list/hotel-list.component.ts
+++ b/src/app/hotel-list/hotel-list.component.ts
@@ -7,6 +7,7 @@ import { Hotel } from '../HotelItem/hotel';
import { HttpClient } from '@angular/common/http';
import { filter, from, last, map, Observable, scan } from 'rxjs';
import { HotelItem } from '../HotelItem/HotelItem.component';
+import { RouterLink } from '@angular/router';
interface User {
name: string;
@@ -16,7 +17,7 @@ interface User {
@Component({
selector: 'app-hotel-list',
standalone: true,
- imports: [UpperCasePipe, TextPipe, SearchComponent, HotelItem, NgFor, NgIf],
+ imports: [UpperCasePipe, TextPipe, SearchComponent, HotelItem, NgFor, NgIf, RouterLink],
templateUrl: './hotel-list.component.html',
styleUrl: './hotel-list.component.css'
})
diff --git a/src/app/new-hotel/new-hotel.component.css b/src/app/new-hotel/new-hotel.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/new-hotel/new-hotel.component.html b/src/app/new-hotel/new-hotel.component.html
new file mode 100644
index 0000000..b3a3ac1
--- /dev/null
+++ b/src/app/new-hotel/new-hotel.component.html
@@ -0,0 +1,16 @@
+
Create Hotel
+
+
diff --git a/src/app/new-hotel/new-hotel.component.spec.ts b/src/app/new-hotel/new-hotel.component.spec.ts
new file mode 100644
index 0000000..33b658c
--- /dev/null
+++ b/src/app/new-hotel/new-hotel.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { NewHotelComponent } from './new-hotel.component';
+
+describe('NewHotelComponent', () => {
+ let component: NewHotelComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [NewHotelComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(NewHotelComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/new-hotel/new-hotel.component.ts b/src/app/new-hotel/new-hotel.component.ts
new file mode 100644
index 0000000..d5bfd19
--- /dev/null
+++ b/src/app/new-hotel/new-hotel.component.ts
@@ -0,0 +1,47 @@
+import { HttpClient } from '@angular/common/http';
+import { Component } from '@angular/core';
+import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
+import { Router, RouterLink } from '@angular/router';
+import { Hotel } from '../HotelItem/hotel';
+import { NgFor, NgIf } from '@angular/common';
+
+@Component({
+ selector: 'app-new-hotel',
+ standalone: true,
+ imports: [ReactiveFormsModule, NgIf, NgFor, RouterLink],
+ templateUrl: './new-hotel.component.html',
+ styleUrl: './new-hotel.component.css'
+})
+export class NewHotelComponent {
+ public hotelForm!: FormGroup
+ public hotel!: Hotel
+
+ ngOnInit(): void {
+ this.hotelForm = new FormGroup({
+ name: new FormControl("", Validators.required),
+ description: new FormControl("", Validators.required),
+ price: new FormControl(0, Validators.required),
+ imageUrl: new FormControl("", Validators.required),
+ rating: new FormControl(0, Validators.required),
+ })
+ }
+
+ constructor(public http: HttpClient, public router: Router) {
+
+ }
+
+ submit(): void {
+ console.log(this.hotelForm.value);
+ const hotel: Hotel = {
+ id: 0,
+ hotelName: this.hotelForm.get("name")?.value,
+ description: this.hotelForm.get("description")?.value,
+ price: this.hotelForm.get("price")?.value,
+ imageUrl: this.hotelForm.get("imageUrl")?.value,
+ rating: this.hotelForm.get("rating")?.value,
+ tags: []
+ }
+ this.http.post("/api/hotels/", hotel).subscribe();
+ this.router.navigate(["/"]);
+ }
+}
diff --git a/src/index.html b/src/index.html
index f3614f8..3d91cf2 100644
--- a/src/index.html
+++ b/src/index.html
@@ -8,7 +8,7 @@
-
+