Compare commits

...

2 Commits

Author SHA1 Message Date
8d6129590a
Fixing user info reading at page load
All checks were successful
Jenkins Production Deployment
2022-09-26 17:59:36 +02:00
13aa2c29b0
Fix bug where summary page was displayed together with extra points page 2022-09-26 17:45:17 +02:00
3 changed files with 38 additions and 4 deletions

View File

@ -61,9 +61,9 @@
<p id="foxes-warn" *ngIf="!checkTotalFoxPoints()">Please check the number of caught foxes!</p>
<button (click)="switchToNextPage()" [disabled]="!checkAllExtraPoints()">Next</button>
</div>
<div id="summary" class="visible-{{this.currentPage === 5}}">
<div id="summary" class="visible-{{this.currentPage === 6}}">
<p>Game Summary</p>
<button>Save Game</button>
<button (click)="saveGame()">Save Game</button>
</div>
</div>
<div id="scores">

View File

@ -702,4 +702,22 @@ export class AddGameComponent implements OnInit {
checkAllExtraPoints(): boolean {
return this.checkTotalFoxPoints();
}
/**
* _____
* / ___/__ ______ ___ ____ ___ ____ ________ __
* \__ \/ / / / __ `__ \/ __ `__ \/ __ `/ ___/ / / /
* ___/ / /_/ / / / / / / / / / / / /_/ / / / /_/ /
* /____/\__,_/_/ /_/ /_/_/ /_/ /_/\__,_/_/ \__, /
* /____/
*/
/**
* Sends the game stats to the API to be saved
*/
saveGame(): void {
//TODO implement
// call api method, then return to gameNight page / close modal or sth like that
window.location.reload();
}
}

View File

@ -17,8 +17,20 @@ export class HomeComponent implements OnInit {
}
ngOnInit(): void {
// TODO: First try to read existing session data
this.authenticateUser();
if(!HomeComponent.sessionDataAvailable()) {
this.authenticateUser();
window.location.reload();
}
}
/**
* Checks if there is session data saved in the local storage
* @return If there is session data available
*/
private static sessionDataAvailable(): boolean {
let user = StorageService.getUserInfo();
return user !== undefined;
}
/**
@ -35,6 +47,10 @@ export class HomeComponent implements OnInit {
sessionKey: ''
};
if(user.firebonkId === undefined || user.firstName === undefined || user.token === undefined) {
return;
}
let authenticatedUser = ApiService.performAuthentication(user);
StorageService.setUserInfo(authenticatedUser);
});