From c2ffadb7330479d1cdfdb130b0663fc329baf2fe Mon Sep 17 00:00:00 2001 From: Le Deng Date: Fri, 10 Mar 2017 09:39:46 -0500 Subject: [PATCH] latest --- bookstore-api/.idea/workspace.xml | 4 +- store-front/src/app/app.module.ts | 4 +- store-front/src/app/app.routing.ts | 6 ++ .../book-list/book-list.component.html | 2 +- .../components/nav-bar/nav-bar.component.html | 1 + .../shopping-cart/shopping-cart.component.css | 3 + .../shopping-cart.component.html | 75 +++++++++++++++++++ .../shopping-cart.component.spec.ts | 28 +++++++ .../shopping-cart/shopping-cart.component.ts | 26 +++++++ 9 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 store-front/src/app/components/shopping-cart/shopping-cart.component.css create mode 100644 store-front/src/app/components/shopping-cart/shopping-cart.component.html create mode 100644 store-front/src/app/components/shopping-cart/shopping-cart.component.spec.ts create mode 100644 store-front/src/app/components/shopping-cart/shopping-cart.component.ts diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 5df3313..1a06443 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -982,12 +982,12 @@ - + - diff --git a/store-front/src/app/app.module.ts b/store-front/src/app/app.module.ts index 0a13388..19b836a 100644 --- a/store-front/src/app/app.module.ts +++ b/store-front/src/app/app.module.ts @@ -23,6 +23,7 @@ import { MyAccountComponent } from './components/my-account/my-account.component import { MyProfileComponent } from './components/my-profile/my-profile.component'; import { BookListComponent } from './components/book-list/book-list.component'; import { BookDetailComponent } from './components/book-detail/book-detail.component'; +import { ShoppingCartComponent } from './components/shopping-cart/shopping-cart.component'; @NgModule({ declarations: [ @@ -33,7 +34,8 @@ import { BookDetailComponent } from './components/book-detail/book-detail.compon MyAccountComponent, MyProfileComponent, BookListComponent, - BookDetailComponent + BookDetailComponent, + ShoppingCartComponent ], imports: [ BrowserModule, diff --git a/store-front/src/app/app.routing.ts b/store-front/src/app/app.routing.ts index 84dacef..4b660a2 100644 --- a/store-front/src/app/app.routing.ts +++ b/store-front/src/app/app.routing.ts @@ -9,6 +9,8 @@ import {MyAccountComponent} from './components/my-account/my-account.component'; import {MyProfileComponent} from './components/my-profile/my-profile.component'; import {BookListComponent} from './components/book-list/book-list.component'; import {BookDetailComponent} from './components/book-detail/book-detail.component'; +import {ShoppingCartComponent} from './components/shopping-cart/shopping-cart.component'; + const appRoutes: Routes = [ { @@ -35,6 +37,10 @@ const appRoutes: Routes = [ { path: 'bookDetail/:id', component: BookDetailComponent + }, + { + path: 'shoppingCart', + component: ShoppingCartComponent } ]; diff --git a/store-front/src/app/components/book-list/book-list.component.html b/store-front/src/app/components/book-list/book-list.component.html index f216429..0b6b704 100644 --- a/store-front/src/app/components/book-list/book-list.component.html +++ b/store-front/src/app/components/book-list/book-list.component.html @@ -36,7 +36,7 @@ {{book.format | uppercase}} {{book.numberOfPages}} pages
- ${{book.ourPrice | number : '1.2-2'}} ${{book.listPrice | number : '1.2-2'}} diff --git a/store-front/src/app/components/nav-bar/nav-bar.component.html b/store-front/src/app/components/nav-bar/nav-bar.component.html index ed68244..381fb74 100644 --- a/store-front/src/app/components/nav-bar/nav-bar.component.html +++ b/store-front/src/app/components/nav-bar/nav-bar.component.html @@ -21,6 +21,7 @@
  • MY ACCOUNT
  • +
  • SHOPPING CART
  • MY PROFILE
  • LOGOUT
  • diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.css b/store-front/src/app/components/shopping-cart/shopping-cart.component.css new file mode 100644 index 0000000..45bdfed --- /dev/null +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.css @@ -0,0 +1,3 @@ +.text-strike { + text-decoration: line-through; +} \ No newline at end of file diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.html b/store-front/src/app/components/shopping-cart/shopping-cart.component.html new file mode 100644 index 0000000..8439667 --- /dev/null +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.html @@ -0,0 +1,75 @@ +
    +
    +
    +

    Shopping Cart

    +
    +
    + +
    +
    +
    + +
    +
    + +
    +
    + Oops, some of the products don't have enough stock. Please update product quantity. +
    +
    + Oops, your cart is empty. See if you can find what you like in the bookshelf and add them to cart. +
    +
    +
    +

    Products

    +
    +

    Price

    +
    +

    Qty

    +
    + +
    +
    +
    +
    + +
    +
    +

    + {{cartItem.book.title}}

    +

    In Stock

    +

    Only {{cartItem.book.inStockNumber}} In Stock +

    +

    Product Unavailable

    + delete +
    +
    +
    ${{cartItem.book.ourPrice}} +
    +
    +
    + + + +
    +
    +
    +
    +
    +

    Total Price ( items): $

    +
    +
    +
    +
    diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.spec.ts b/store-front/src/app/components/shopping-cart/shopping-cart.component.spec.ts new file mode 100644 index 0000000..334e75f --- /dev/null +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.spec.ts @@ -0,0 +1,28 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { ShoppingCartComponent } from './shopping-cart.component'; + +describe('ShoppingCartComponent', () => { + let component: ShoppingCartComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ShoppingCartComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShoppingCartComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts new file mode 100644 index 0000000..86ff6dc --- /dev/null +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; +import {AppConst} from '../../constants/app-const'; +import {Book} from '../../models/book'; +import {Router} from "@angular/router"; + + +@Component({ + selector: 'app-shopping-cart', + templateUrl: './shopping-cart.component.html', + styleUrls: ['./shopping-cart.component.css'] +}) +export class ShoppingCartComponent implements OnInit { + private serverPath = AppConst.serverPath; + private selectedBook: Book; + + constructor(private router:Router) { } + + onSelect(book:Book) { + this.selectedBook = book; + this.router.navigate(['/bookDetail', this.selectedBook.id]); + } + + ngOnInit() { + } + +}