Skip to content

Commit 4ddc2d8

Browse files
authored
Merge pull request #2 from sonderformat-llc/main
feat: add Make Change page
2 parents 4928a76 + 4fe8d5a commit 4ddc2d8

8 files changed

Lines changed: 56 additions & 13 deletions

File tree

complete-application/src/app/account-page/account-page.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Component } from '@angular/core';
2+
import {CommonModule} from "@angular/common";
23

34
@Component({
45
selector: 'app-account-page',
6+
standalone: true,
7+
imports: [CommonModule],
58
templateUrl: './account-page.component.html',
69
styleUrls: ['./account-page.component.css']
710
})

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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,32 @@ import {NgModule} from '@angular/core';
22
import {BrowserModule} from '@angular/platform-browser';
33
import {AppComponent} from './app.component';
44
import {RouterModule} from "@angular/router";
5-
import {HomePageComponent} from './home-page/home-page.component';
65
//tag::importAngularSDK[]
76
import {FusionAuthModule} from "@fusionauth/angular-sdk";
87
//end::importAngularSDK[]
9-
import {AccountPageComponent} from './account-page/account-page.component';
108
//tag::importAuthGuard[]
119
import {authGuard} from "./auth-guard";
1210
//end::importAuthGuard[]
1311

1412
@NgModule({
1513
declarations: [
16-
AppComponent,
17-
HomePageComponent,
18-
AccountPageComponent
14+
AppComponent
1915
],
2016
imports: [
2117
BrowserModule,
2218
//tag::routerConfiguration[]
2319
RouterModule.forRoot([
24-
{path: '', component: HomePageComponent, canActivate: [authGuard(false, '/account')]},
25-
{path: 'account', component: AccountPageComponent, canActivate: [authGuard(true, '/')]}
20+
{path: '', loadComponent: () => import('./home-page/home-page.component').then(m => m.HomePageComponent), canActivate: [authGuard(false, '/account')]},
21+
{path: 'account', loadComponent: () => import('./account-page/account-page.component').then(m => m.AccountPageComponent), canActivate: [authGuard(true, '/')]},
22+
{path: 'make-change', loadComponent: () => import('./make-change-page/make-change-page.component').then(m => m.MakeChangePageComponent), canActivate: [authGuard(true, '/')]},
2623
]),
2724
//end::routerConfiguration[]
2825
//tag::fusionAuthModuleConfiguration[]
2926
FusionAuthModule.forRoot({
3027
clientId: 'e9fdb985-9173-4e01-9d73-ac2d60d1dc8e',
3128
serverUrl: 'http://localhost:9011',
3229
redirectUri: 'http://localhost:4200',
33-
})
30+
}),
3431
//end::fusionAuthModuleConfiguration[]
3532
],
3633
providers: [],

complete-application/src/app/home-page/home-page.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import {Component, inject} from '@angular/core';
22
import {FusionAuthService} from "@fusionauth/angular-sdk";
3+
import {CommonModule} from "@angular/common";
34

45
@Component({
56
selector: 'app-home-page',
7+
standalone: true,
8+
imports: [CommonModule],
69
templateUrl: './home-page.component.html',
710
styleUrls: ['./home-page.component.css']
811
})

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Component } from '@angular/core';
2+
import {CommonModule} from "@angular/common";
3+
import {FormsModule} from "@angular/forms";
4+
5+
@Component({
6+
selector: 'app-make-change-page',
7+
standalone: true,
8+
imports: [CommonModule, FormsModule],
9+
templateUrl: './make-change-page.component.html',
10+
styleUrls: ['./make-change-page.component.css']
11+
})
12+
export class MakeChangePageComponent {
13+
14+
amount = 0;
15+
16+
change: { total: number; nickels: number; pennies: number } | null = null;
17+
18+
makeChange() {
19+
const total = this.amount;
20+
const nickels = Math.floor(this.amount / 0.05);
21+
const pennies = Math.round((this.amount - nickels * 0.05) * 100);
22+
this.change = {nickels, pennies, total};
23+
}
24+
25+
}

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)