feat(home): display user balance on home page

This commit is contained in:
Jan K9f 2025-02-27 15:42:16 +01:00
parent 6bd2928166
commit a9ed3c4a9a
2 changed files with 19 additions and 4 deletions

View file

@ -59,6 +59,12 @@
<div class="lg:col-span-1 space-y-6">
<div class="card p-4">
<h3 class="section-heading text-xl mb-4">Konto</h3>
<div *ngIf="user" class="mb-4 p-3 bg-deep-blue-light rounded">
<div class="flex justify-between items-center">
<span class="text-sm text-text-secondary">Kontostand</span>
<span class="text-xl font-bold text-emerald">{{ user.balance | currency: 'EUR' }}</span>
</div>
</div>
<div class="space-y-4">
<button class="button-base w-full py-2" (click)="openDepositModal()">Einzahlen</button>
<app-deposit [isOpen]="isDepositModalOpen" (close)="closeDepositModal()"></app-deposit>

View file

@ -1,19 +1,28 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { NavbarComponent } from '../../shared/components/navbar/navbar.component';
import { CurrencyPipe, NgFor } from '@angular/common';
import { CurrencyPipe, NgFor, NgIf } from '@angular/common';
import { Game } from '../../model/Game';
import { Transaction } from '../../model/Transaction';
import { DepositComponent } from '../deposit/deposit.component';
import { User } from '../../model/User';
@Component({
selector: 'app-homepage',
standalone: true,
imports: [NavbarComponent, CurrencyPipe, NgFor, DepositComponent],
imports: [NavbarComponent, CurrencyPipe, NgFor, NgIf, DepositComponent],
templateUrl: './home.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class HomeComponent {
export default class HomeComponent implements OnInit {
isDepositModalOpen = false;
user: User | null = null;
ngOnInit(): void {
const userJson = sessionStorage.getItem('user');
if (userJson) {
this.user = JSON.parse(userJson);
}
}
featuredGames: Game[] = [
{