Task breakdown:
- Create a view of the shop products that should contain: Name, Price and Pets list.
- Dropdown controller to Filter the products by pet (See image below).
- Radio button Controller to Filter products by vegetarian/non vegetarian.
- If the user chooses vegetarian products the pets list in the dropdown should contains only a vegetarian pets (See image below).
- Create a header with a cart icon that contains a counter with the number of products added to the cart.
- Clicking on a product will redirect to a product view that will contain the following:
- Product Image.
- Pets list that can use this product.
- Product price.
- If the product is for Vegetarian pets only.
- Button “Add To Cart”.
- Clicking on “Add To Cart” button will open a dialog that asks the user if this product should be added to the cart.
- Clicking the header cart icon will redirect the user to the cart view.
- The cart view will contain a list with the products and the total amount, For example:
The Requirements:
- Angular4 (Angular CLI).
- Reactive programming (RxJS).
- Unit testing (Your solution should be fully tested).
- The code should be modular.
- Division of responsibility between the code parts.
- Code Reuse (TS & HTML).
- Readable Code.
- Angular material for the view elements.
- Restful.
- Use the existing backend mocks, under "mocks" folder (See the "how to use" example).
import {Injectable} from '@angular/core';
import {Http, Response} from "@angular/http";
import {MockPetsAPI} from "./mocks/mock-pets-api.service";
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map'
@Injectable()
export class PetsApiService {
public constructor(private http: Http, private mockPetsAPI: MockPetsAPI) {
this.mockPetsAPI.handleRequest(); // Execute the mock
}
private get getBaseUrl(): string {
return `/pets/`;
}
// Get an observable of pets
public getPets(): Observable<MyType> {
return this.http.get(this.getBaseUrl).map((response: Response) => {
const petsList: any = response.json();
return petsList;
});
}
}