style: run prettier

This commit is contained in:
Phan Huy Tran 2025-05-07 13:58:56 +02:00
commit efc2a8ecec
5 changed files with 49 additions and 44 deletions

View file

@ -31,8 +31,12 @@
</div> </div>
<div [ngClass]="slotResult().status === 'win' ? 'text-green-500' : 'text-red-500'"> <div [ngClass]="slotResult().status === 'win' ? 'text-green-500' : 'text-red-500'">
<p>Game result: <strong>{{ slotResult().status | uppercase }}</strong></p> <p>
<p>Amount: <strong>{{ slotResult().amount }}</strong></p> Game result: <strong>{{ slotResult().status | uppercase }}</strong>
</p>
<p>
Amount: <strong>{{ slotResult().amount }}</strong>
</p>
</div> </div>
<div> <div>

View file

@ -1,8 +1,8 @@
import {ChangeDetectionStrategy, Component, inject, OnInit, signal} from "@angular/core"; import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
import {NavbarComponent} from "@shared/components/navbar/navbar.component"; import { NavbarComponent } from '@shared/components/navbar/navbar.component';
import {HttpClient} from "@angular/common/http"; import { HttpClient } from '@angular/common/http';
import {KeyValuePipe, NgClass, UpperCasePipe} from "@angular/common"; import { KeyValuePipe, NgClass, UpperCasePipe } from '@angular/common';
import {FormsModule} from "@angular/forms"; import { FormsModule } from '@angular/forms';
interface SlotResult { interface SlotResult {
status: 'win' | 'lose'; status: 'win' | 'lose';
@ -13,13 +13,7 @@ interface SlotResult {
@Component({ @Component({
selector: 'app-slots', selector: 'app-slots',
standalone: true, standalone: true,
imports: [ imports: [NavbarComponent, KeyValuePipe, UpperCasePipe, NgClass, FormsModule],
NavbarComponent,
KeyValuePipe,
UpperCasePipe,
NgClass,
FormsModule
],
templateUrl: './slots.component.html', templateUrl: './slots.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
@ -30,25 +24,25 @@ export default class SlotsComponent implements OnInit {
status: 'lose', status: 'lose',
amount: 12, amount: 12,
resultMatrix: [ resultMatrix: [
["BAR", "BAR", "BAR"], ['BAR', 'BAR', 'BAR'],
["SEVEN", "SEVEN", "SEVEN"], ['SEVEN', 'SEVEN', 'SEVEN'],
["BELL", "BELL", "BELL"] ['BELL', 'BELL', 'BELL'],
] ],
}); });
betAmount = signal<number>(1); betAmount = signal<number>(1);
ngOnInit(): void { ngOnInit(): void {
this.httpClient.get<Record<string, number>>('/backend/slots/info').subscribe(data => { this.httpClient.get<Record<string, number>>('/backend/slots/info').subscribe((data) => {
this.slotInfo.set(data); this.slotInfo.set(data);
}); });
} }
spin(): void { spin(): void {
const payload = { const payload = {
betAmount: this.betAmount() betAmount: this.betAmount(),
}; };
this.httpClient.post<SlotResult>('/backend/slots/spin', payload).subscribe(result => { this.httpClient.post<SlotResult>('/backend/slots/spin', payload).subscribe((result) => {
this.slotResult.set(result); this.slotResult.set(result);
}); });
} }

View file

@ -1,4 +1,11 @@
import {ChangeDetectionStrategy, Component, EventEmitter, inject, Input, Output,} from '@angular/core'; import {
ChangeDetectionStrategy,
Component,
EventEmitter,
inject,
Input,
Output,
} from '@angular/core';
import { TransactionService } from '@service/transaction.service'; import { TransactionService } from '@service/transaction.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { AsyncPipe, CurrencyPipe, DatePipe, NgIf } from '@angular/common'; import { AsyncPipe, CurrencyPipe, DatePipe, NgIf } from '@angular/common';