Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ Simple application for booking flights.

## Criteria

- [x] *-- No authentication for now --*
- [ ] Pick random profile on load to book
- [ ] Use Angular State management to store current profile
- [x] _-- No authentication for now --_
- [x] Pick random profile on load to book
- [x] Use Angular State management to store current profile
- [x] Build mock server for testing and development
- [x] Use faker to generate mock data in mocked services
- [ ] Add angular material to layout
- [ ] Create booking page
- [ ] Implement flight search functionality
- [ ] Use mock data for flights
- [ ] Display search results in a user-friendly format
- [ ] Display additional flight details
- [x] Add angular material to layout
- [] Create booking page
- [x] Implement flight search functionality
- [x] Use mock data for flights
- [x] Display search results in a user-friendly format
- [x] Display additional flight details
- [ ] Implement admin functionalities
- [x] List all profiles
- [ ] Search profiles by username, firstname or lastname
- [ ] View profile details
- [ ] View booked flights per profile
- [x] Search profiles by username, firstname or lastname
- [x] View profile details
- [ ] View booked flights per profile
45 changes: 40 additions & 5 deletions mocks/services/flight.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { Injectable } from '@angular/core';
import { faker } from '@faker-js/faker';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { Flight } from 'src/app/models/flight';

const planeBrands = ['Boeing', 'Airbus', 'Concorde', 'Embraer', 'Bombardier'];

@Injectable({
providedIn: 'root',
})
export class FlightService {
constructor() { }
constructor() {}

private bookedFlightsSubject = new BehaviorSubject<Flight[]>([]);
public bookedFlights$: Observable<Flight[]> =
this.bookedFlightsSubject.asObservable();

getFlights(): Flight[] {
public getFlights(): Observable<Flight[]> {
const flights: Flight[] = [];

for (let i = 1; i <= 10; i++) {
flights.push({
id: i,
Expand All @@ -14,9 +26,32 @@ export class FlightService {
arrival: faker.location.city(),
departureTime: faker.date.future(),
arrivalTime: faker.date.future(),
price: parseFloat(faker.commerce.price())
price: parseFloat(faker.commerce.price()),
cargoCapacity: faker.number.float({ min: 3000, max: 5000 }).toFixed(),
planeAge: faker.number.float({ min: 5, max: 20 }).toFixed(),
planeType:
planeBrands[Math.ceil(Math.random() * planeBrands.length - 1)],
});
}
return flights;

return of(flights);
}

public getCurrentBookedFlights(): Flight[] {
return this.bookedFlightsSubject.getValue();
}

public addFlightToCurrentBookedFlights(flight: Flight): void {
const currentBookedFlights = this.bookedFlightsSubject.getValue();

this.bookedFlightsSubject.next([...currentBookedFlights, flight]);
}

public removeFlightFromCurrentBookedFlights(id: number): void {
const updated = this.bookedFlightsSubject
.getValue()
.filter((flight) => flight.id !== id);

this.bookedFlightsSubject.next(updated);
}
}
}
21 changes: 17 additions & 4 deletions mocks/services/user.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { faker } from '@faker-js/faker';
import { Observable, of } from 'rxjs';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { UserProfile } from 'src/app/models/profile';

export class UserService {
private _profiles: UserProfile[] = [];

private randomProfileSubject = new BehaviorSubject<UserProfile | undefined>(
undefined
);
public randomProfile$ = this.randomProfileSubject.asObservable();

constructor() {
this.generateProfiles();
}
Expand All @@ -24,13 +29,21 @@ export class UserService {
city: faker.location.city(),
state: faker.location.state(),
zipCode: faker.location.zipCode(),
country: faker.location.country()
}
country: faker.location.country(),
},
});
}
}

public getUsers(): Observable<UserProfile[]> {
return of(this._profiles);
}
}

public setCurrentUser(user: UserProfile): void {
this.randomProfileSubject.next(user);
}

public getCurrentUser(): UserProfile | undefined {
return this.randomProfileSubject.getValue();
}
}
Loading