casino/frontend/src/app/feature/home/home.component.ts
Jan-Marlon Leibl eb153f4459
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / Checkstyle Main (pull_request) Has been skipped
CI / prettier (pull_request) Successful in 16s
CI / eslint (pull_request) Failing after 43s
CI / test-build (pull_request) Successful in 46s
feat(game): add blackjack game component and routing
2025-03-26 13:26:38 +01:00

96 lines
2.3 KiB
TypeScript

import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { NavbarComponent } from '../../shared/components/navbar/navbar.component';
import { CurrencyPipe, NgFor } from '@angular/common';
import { Game } from '../../model/Game';
import { Transaction } from '../../model/Transaction';
import { DepositComponent } from '../deposit/deposit.component';
import { ConfirmationComponent } from '../../shared/components/confirmation/confirmation.component';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-homepage',
standalone: true,
imports: [NavbarComponent, CurrencyPipe, NgFor, DepositComponent, ConfirmationComponent],
templateUrl: './home.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class HomeComponent implements OnInit {
isDepositModalOpen = false;
isDepositSuccessful = false;
constructor(
public route: ActivatedRoute,
public router: Router
) {}
ngOnInit() {
this.isDepositSuccessful = this.route.snapshot.queryParams['success'] == 'true';
this.router.navigate([], { queryParams: {} });
if (this.isDepositSuccessful) {
this.openDepositConfirmationModal();
}
}
featuredGames: Game[] = [
{
id: '1',
name: 'Poker',
image: '/poker.webp',
route: '/game/poker',
},
{
id: '2',
name: 'Blackjack',
image: '/blackjack.webp',
route: '/game/blackjack',
},
{
id: '3',
name: 'Slots',
image: '/slots.webp',
route: '/game/slots',
},
{
id: '4',
name: 'Plinko',
image: '/plinko.webp',
route: '/game/plinko',
},
{
id: '5',
name: 'Liars Dice',
image: '/liars-dice.webp',
route: '/game/liars-dice',
},
{
id: '6',
name: 'Lootboxen',
image: '/lootbox.webp',
route: '/game/lootbox',
},
];
allGames: Game[] = [...this.featuredGames];
recentTransactions: Transaction[] = [];
openDepositModal() {
this.isDepositModalOpen = true;
}
closeDepositModal() {
this.isDepositModalOpen = false;
}
openDepositConfirmationModal() {
this.isDepositSuccessful = true;
}
closeDepositConfirmationModal() {
this.isDepositSuccessful = false;
}
navigateToGame(route: string) {
this.router.navigate([route]);
}
}