Skip to content

Commit 422991c

Browse files
committed
cart
1 parent 3b17f84 commit 422991c

11 files changed

+178
-317
lines changed

code/frontend/e2e/src/app.e2e-spec.ts

-23
This file was deleted.

code/frontend/e2e/src/app.po.ts

-11
This file was deleted.

code/frontend/src/app/app.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import { EditUserComponent } from './components/users/edit-user.component';
2121
import { GamePageComponent } from './components/games/game-page.component';
2222
import { NgImageSliderModule } from 'ng-image-slider';
2323
import { ControlPanelComponent } from './components/games/control-panel.component';
24-
import { AddGameComponent } from './components/games/add-game.component';
24+
import { CartComponent } from './components/users/cart.component';
2525

2626
@NgModule({
27-
declarations: [AppComponent, BookDetailComponent, BookListComponent, BookFormComponent, LoginComponent, NavbarComponent, RegisterComponent, AppFooterComponent, GamesComponent, SideBlockComponent, ProfileComponent, ErrorComponent, EditUserComponent, GamePageComponent, ControlPanelComponent, AddGameComponent],
27+
declarations: [AppComponent, BookDetailComponent, BookListComponent, BookFormComponent, LoginComponent, NavbarComponent, RegisterComponent, AppFooterComponent, GamesComponent, SideBlockComponent, ProfileComponent, ErrorComponent, EditUserComponent, GamePageComponent, ControlPanelComponent, CartComponent],
2828
imports: [BrowserModule, FormsModule, HttpClientModule, routing, NgbModule, NgImageSliderModule],
2929
bootstrap: [AppComponent]
3030
})

code/frontend/src/app/app.routing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ErrorComponent } from './components/error/error.component';
1111
import { EditUserComponent } from './components/users/edit-user.component';
1212
import { GamePageComponent } from './components/games/game-page.component';
1313
import { ControlPanelComponent } from './components/games/control-panel.component';
14+
import { CartComponent } from './components/users/cart.component';
1415

1516
const appRoutes = [
1617
{ path: 'login', component: LoginComponent },
@@ -21,6 +22,7 @@ const appRoutes = [
2122
{ path: 'editProfile/:id', component: EditUserComponent, canActivate: [AuthGuard]},
2223
{ path: 'game/:id', component: GamePageComponent},
2324
{ path: 'controlPanel', component: ControlPanelComponent, canActivate: [RoleGuard]},
25+
{ path: 'cart/:id', component: CartComponent, canActivate: [AuthGuard]},
2426
{ path: '**', redirectTo: 'error/404' }
2527
]
2628

code/frontend/src/app/components/games/add-game.component.html

-226
This file was deleted.

code/frontend/src/app/components/games/add-game.component.ts

-50
This file was deleted.

code/frontend/src/app/components/navbar/navbar.component.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<li><a role="button" (click)="myProfile()">Profile <span
3535
class="badge pull-right bg-warning">13</span></a>
3636
</li>
37-
<li><a href="/cart/{{currentUser.id}}">My Cart <span class="badge pull-right bg-default">3</span></a>
37+
<li><a (click)="cart()" role="button">My Cart <span class="badge pull-right bg-default">3</span></a>
3838
</li>
3939
<li class="divider"></li>
4040

@@ -47,7 +47,7 @@
4747
</li>
4848

4949
<li class="dropdown dropdown-hover dropdown-cart nav-item">
50-
<a class="fa fa-shopping-cart nav-link" role="button">
50+
<a class="fa fa-shopping-cart nav-link" role="button" (click)="cart()">
5151
</a>
5252
<div class="dropdown-menu dropdown-menu-right dropdown-menu-scrollable" style="width: 300px;">
5353
<ng-template [ngIf]="this.loginService.getCurrentCart().numberOfElements > 0">
@@ -75,20 +75,22 @@ <h4 class="ellipsis"><a href="/game/{{game.id}}">{{game.name}}</a></h4>
7575

7676

7777

78-
<div class="ml-20 mr-20 pull-left" *ngIf="!this.loginService.getCurrentCart().last"><strong>View cart to see all the games</strong> </div>
78+
<div class="ml-20 mr-20 pull-left" *ngIf="!this.loginService.getCurrentCart().last"><strong>View cart
79+
to see all the games</strong> </div>
7980

8081
<div class="ml-20 mr-20 pull-left"><strong>Subtotal:</strong> <span
8182
class="amount">${{totalPrice()}}</span>
8283
</div>
8384
<div class="btn-group pull-right m-15">
84-
<a href="/cart/{{currentUser.id}}" class="btn btn-default btn-sm">View Cart</a>
85+
<a role="button" (click)="cart()" class="btn btn-default btn-sm">View Cart</a>
8586
<a href="/checkout/{{currentUser.id}}" class="btn btn-default btn-sm">Checkout</a>
8687
</div>
8788
</ng-template>
8889

8990

9091
<div class="ml-20 mr-20 pull-right" *ngIf="this.loginService.getCurrentCart().numberOfElements === 0">
91-
<strong>The cart is empty</strong></div>
92+
<strong>The cart is empty</strong>
93+
</div>
9294

9395
</div>
9496
</li>

code/frontend/src/app/components/navbar/navbar.component.ts

+4
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,8 @@ export class NavbarComponent {
9595
controlPanel(){
9696
this.router.navigate(['/controlPanel']);
9797
}
98+
99+
cart(){
100+
this.router.navigate(['/cart/' + this.loginService.currentUser().id]);
101+
}
98102
}

0 commit comments

Comments
 (0)