Skip to content

Commit 50fda36

Browse files
committed
feat: add Make Change page
1 parent 68bb8d0 commit 50fda36

6 files changed

Lines changed: 49 additions & 8 deletions

File tree

complete-application/src/app/app.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
<div id="menu-bar" class="menu-bar">
1919
<ng-container *ngIf="isLoggedIn">
20-
<a class="menu-link">Make Change</a>
21-
22-
<a class="menu-link" style="text-decoration-line: underline">Account</a>
20+
<a class="menu-link" routerLink="make-change" routerLinkActive="active">Make Change</a>
21+
<a class="menu-link" routerLink="account" routerLinkActive="active">Account</a>
2322
</ng-container>
2423
<ng-container *ngIf="!isLoggedIn">
2524
<a class="menu-link">About</a>

complete-application/src/app/app.module.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {BrowserModule} from '@angular/platform-browser';
33
import {AppComponent} from './app.component';
44
import {RouterModule} from "@angular/router";
55
import {HomePageComponent} from './home-page/home-page.component';
6+
import {FormsModule} from "@angular/forms";
67
//tag::importAngularSDK[]
78
import {FusionAuthModule} from "@fusionauth/angular-sdk";
89
//end::importAngularSDK[]
910
import {AccountPageComponent} from './account-page/account-page.component';
11+
import {MakeChangePageComponent} from './make-change-page/make-change-page.component';
1012
//tag::importAuthGuard[]
1113
import {authGuard} from "./auth-guard";
1214
//end::importAuthGuard[]
@@ -15,22 +17,25 @@ import {authGuard} from "./auth-guard";
1517
declarations: [
1618
AppComponent,
1719
HomePageComponent,
18-
AccountPageComponent
20+
AccountPageComponent,
21+
MakeChangePageComponent
1922
],
2023
imports: [
2124
BrowserModule,
25+
FormsModule,
2226
//tag::routerConfiguration[]
2327
RouterModule.forRoot([
2428
{path: '', component: HomePageComponent, canActivate: [authGuard(false, '/account')]},
25-
{path: 'account', component: AccountPageComponent, canActivate: [authGuard(true, '/')]}
29+
{path: 'account', component: AccountPageComponent, canActivate: [authGuard(true, '/')]},
30+
{path: 'make-change', component: MakeChangePageComponent, canActivate: [authGuard(true, '/')]},
2631
]),
2732
//end::routerConfiguration[]
2833
//tag::fusionAuthModuleConfiguration[]
2934
FusionAuthModule.forRoot({
3035
clientId: 'e9fdb985-9173-4e01-9d73-ac2d60d1dc8e',
3136
serverUrl: 'http://localhost:9011',
3237
redirectUri: 'http://localhost:4200',
33-
})
38+
}),
3439
//end::fusionAuthModuleConfiguration[]
3540
],
3641
providers: [],

complete-application/src/app/make-change-page/make-change-page.component.css

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="app-container change-container">
2+
<h3>We Make Change</h3>
3+
4+
<div class="change-message" *ngIf="change">
5+
We can make change for {{change.total | currency}} with {{change.nickels}} nickels and {{change.pennies}} pennies!
6+
</div>
7+
8+
<form (ngSubmit)="makeChange()">
9+
<div class="h-row">
10+
<div class="change-label">Amount in USD: $</div>
11+
<input class="change-input" name="amount" [(ngModel)]="amount" type="number" step=".01"/>
12+
<input class="change-submit" type="submit" value="Make Change"/>
13+
</div>
14+
</form>
15+
</div>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-make-change-page',
5+
templateUrl: './make-change-page.component.html',
6+
styleUrls: ['./make-change-page.component.css']
7+
})
8+
export class MakeChangePageComponent {
9+
10+
amount = 0;
11+
12+
change: { total: number; nickels: number; pennies: number } | null = null;
13+
14+
makeChange() {
15+
const total = this.amount;
16+
const nickels = Math.floor(this.amount / 0.05);
17+
const pennies = Math.round((this.amount - nickels * 0.05) * 100);
18+
this.change = {nickels, pennies, total};
19+
}
20+
21+
}

complete-application/src/styles.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ body {
7272
font-weight: 600;
7373
color: #FFFFFF;
7474
margin-left: 40px;
75+
text-decoration-line: none;
7576
}
7677

77-
.inactive {
78-
text-decoration-line: none;
78+
.active {
79+
text-decoration-line: underline;
7980
}
8081

8182
.button-lg {

0 commit comments

Comments
 (0)