feat: add user balance updates during lootbox opening #169

Merged
jleibl merged 4 commits from task/CAS-44/lootbox-selection into main 2025-05-07 13:33:11 +00:00
6 changed files with 21 additions and 21 deletions
Showing only changes of commit c92a182123 - Show all commits

View file

@ -34,7 +34,7 @@
[disabled]="!hasEnoughBalance()" [disabled]="!hasEnoughBalance()"
[ngClass]="{ [ngClass]="{
'button-primary': hasEnoughBalance(), 'button-primary': hasEnoughBalance(),
'bg-gray-500 cursor-not-allowed': !hasEnoughBalance() 'bg-gray-500 cursor-not-allowed': !hasEnoughBalance(),
}" }"
class="w-full py-3 text-lg font-semibold rounded" class="w-full py-3 text-lg font-semibold rounded"
> >
@ -96,7 +96,7 @@
[disabled]="!animationCompleted || !hasEnoughBalance()" [disabled]="!animationCompleted || !hasEnoughBalance()"
[ngClass]="{ [ngClass]="{
'button-primary': hasEnoughBalance(), 'button-primary': hasEnoughBalance(),
'bg-gray-500 cursor-not-allowed': !hasEnoughBalance() 'bg-gray-500 cursor-not-allowed': !hasEnoughBalance(),
}" }"
class="px-6 py-2 font-semibold rounded" class="px-6 py-2 font-semibold rounded"
[attr.aria-hidden]="!animationCompleted" [attr.aria-hidden]="!animationCompleted"

View file

@ -33,7 +33,7 @@ export default class LootboxOpeningComponent {
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef
) { ) {
this.loadLootbox(); this.loadLootbox();
this.userService.currentUser$.subscribe(user => { this.userService.currentUser$.subscribe((user) => {
this.currentUser = user; this.currentUser = user;
this.cdr.detectChanges(); this.cdr.detectChanges();
}); });

View file

@ -47,7 +47,7 @@
[disabled]="!hasEnoughBalance(lootbox.price)" [disabled]="!hasEnoughBalance(lootbox.price)"
[ngClass]="{ [ngClass]="{
'button-primary': hasEnoughBalance(lootbox.price), 'button-primary': hasEnoughBalance(lootbox.price),
'bg-gray-500 cursor-not-allowed': !hasEnoughBalance(lootbox.price) 'bg-gray-500 cursor-not-allowed': !hasEnoughBalance(lootbox.price),
}" }"
class="w-full py-2 rounded font-semibold" class="w-full py-2 rounded font-semibold"
> >

View file

@ -95,7 +95,7 @@ export default class LootboxSelectionComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.loadLootboxes(); this.loadLootboxes();
this.userService.currentUser$.subscribe(user => { this.userService.currentUser$.subscribe((user) => {
this.currentUser = user; this.currentUser = user;
this.cdr.detectChanges(); this.cdr.detectChanges();
}); });
@ -128,7 +128,7 @@ export default class LootboxSelectionComponent implements OnInit {
} }
openLootbox(lootboxId: number): void { openLootbox(lootboxId: number): void {
const lootbox = this.lootboxes.find(box => box.id === lootboxId); const lootbox = this.lootboxes.find((box) => box.id === lootboxId);
if (!lootbox) { if (!lootbox) {
return; return;

View file

@ -38,7 +38,7 @@ export class UserService {
if (currentUser) { if (currentUser) {
const updatedUser = { const updatedUser = {
...currentUser, ...currentUser,
balance: currentUser.balance + amount balance: currentUser.balance + amount,
}; };
this.currentUserSubject.next(updatedUser); this.currentUserSubject.next(updatedUser);
} }