feat: add transaction history to homepage (CAS-56) #137
6 changed files with 57 additions and 12 deletions
|
@ -16,6 +16,6 @@ public interface TransactionRepository extends JpaRepository<TransactionEntity,
|
||||||
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1")
|
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1")
|
||||||
List<TransactionEntity> findAllByUserId(UserEntity id);
|
List<TransactionEntity> findAllByUserId(UserEntity id);
|
||||||
|
|
||||||
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1 ORDER BY t.id DESC LIMIT ?2")
|
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1 ORDER BY t.createdAt DESC LIMIT ?2")
|
||||||
List<TransactionEntity> findByUserIdWithLimit(UserEntity userEntity, Integer limit);
|
List<TransactionEntity> findByUserIdWithLimit(UserEntity userEntity, Integer limit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,10 @@
|
||||||
[isOpen]="isDepositModalOpen"
|
[isOpen]="isDepositModalOpen"
|
||||||
(closeModalEmitter)="closeDepositModal()"
|
(closeModalEmitter)="closeDepositModal()"
|
||||||
></app-deposit>
|
></app-deposit>
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded" (click)="openTransactionModal()">
|
||||||
Transaktionen
|
Transaktionen
|
||||||
</button>
|
</button>
|
||||||
|
<app-transaction-history [isOpen]="isTransactionModalOpen" (closeEventEmitter)="closeTransactionModal()" />
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
||||||
Kontoeinstellungen
|
Kontoeinstellungen
|
||||||
</button>
|
</button>
|
||||||
|
@ -103,8 +104,8 @@
|
||||||
*ngFor="let transaction of recentTransactions|async"
|
*ngFor="let transaction of recentTransactions|async"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-sm font-medium">{{ transaction.type }}</p>
|
<p class="text-sm font-medium">{{ transaction.status }}</p>
|
||||||
<p class="text-xs text-text-secondary">{{ transaction.createdAt | date }}</p>
|
<p class="text-xs text-text-secondary">{{ transaction.createdAt | date : 'd.m.Y H:m'}}</p>
|
||||||
</div>
|
</div>
|
||||||
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
||||||
{{ transaction.amount | currency: 'EUR' }}
|
{{ transaction.amount | currency: 'EUR' }}
|
||||||
|
|
|
@ -8,22 +8,26 @@ import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||||
import { Game } from 'app/model/Game';
|
import { Game } from 'app/model/Game';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { TransactionService } from '@service/transaction.service';
|
import { TransactionService } from '@service/transaction.service';
|
||||||
|
import format from 'ajv/dist/vocabularies/format';
|
||||||
|
import { TransactionHistoryComponent } from '../transaction-history/transaction-history.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-homepage',
|
selector: 'app-homepage',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [NavbarComponent, CurrencyPipe, NgFor, DepositComponent, ConfirmationComponent, AsyncPipe, DatePipe],
|
imports: [NavbarComponent, CurrencyPipe, NgFor, DepositComponent, ConfirmationComponent, AsyncPipe, DatePipe, TransactionHistoryComponent],
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export default class HomeComponent implements OnInit {
|
export default class HomeComponent implements OnInit {
|
||||||
isDepositModalOpen = false;
|
isDepositModalOpen = false;
|
||||||
isDepositSuccessful = false;
|
isDepositSuccessful = false;
|
||||||
|
isTransactionModalOpen = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public router: Router
|
public router: Router,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isDepositSuccessful = this.route.snapshot.queryParams['success'] == 'true';
|
this.isDepositSuccessful = this.route.snapshot.queryParams['success'] == 'true';
|
||||||
|
@ -81,6 +85,7 @@ export default class HomeComponent implements OnInit {
|
||||||
openDepositModal() {
|
openDepositModal() {
|
||||||
this.isDepositModalOpen = true;
|
this.isDepositModalOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDepositModal() {
|
closeDepositModal() {
|
||||||
this.isDepositModalOpen = false;
|
this.isDepositModalOpen = false;
|
||||||
}
|
}
|
||||||
|
@ -88,11 +93,23 @@ export default class HomeComponent implements OnInit {
|
||||||
openDepositConfirmationModal() {
|
openDepositConfirmationModal() {
|
||||||
this.isDepositSuccessful = true;
|
this.isDepositSuccessful = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openTransactionModal()
|
||||||
|
{
|
||||||
|
this.isTransactionModalOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
closeDepositConfirmationModal() {
|
closeDepositConfirmationModal() {
|
||||||
this.isDepositSuccessful = false;
|
this.isDepositSuccessful = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeTransactionModal() {
|
||||||
|
this.isTransactionModalOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
navigateToGame(route: string) {
|
navigateToGame(route: string) {
|
||||||
this.router.navigate([route]);
|
this.router.navigate([route]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly format = format;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,10 @@
|
||||||
<p>transaction-history works!</p>
|
<div *ngIf="isOpen" [@fadeInOut] class="modal-bg" style="z-index: 1000; position: fixed;">
|
||||||
|
<div class="modal-card" [@cardAnimation]>
|
||||||
|
<h2 class="modal-heading">Transaktionen</h2>
|
||||||
|
<p class="py-2 text-text-secondary mb-4">Hier siehst du alle vergangenen Einzahlungen</p>
|
||||||
|
|
||||||
|
<button type="button" (click)="closeDialog()" class="button-primary w-full py-2">
|
||||||
|
Verstanden
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,17 +1,35 @@
|
||||||
import { ChangeDetectionStrategy, Component, inject } 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 { Transaction } from '../../model/Transaction';
|
||||||
|
import { AsyncPipe, CurrencyPipe, DatePipe, NgForOf, NgIf } from '@angular/common';
|
||||||
|
import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
selector: 'app-transaction-history',
|
selector: 'app-transaction-history',
|
||||||
imports: [],
|
imports: [
|
||||||
|
NgForOf,
|
||||||
|
AsyncPipe,
|
||||||
|
CurrencyPipe,
|
||||||
|
DatePipe,
|
||||||
|
AnimatedNumberComponent,
|
||||||
|
NgIf,
|
||||||
|
],
|
||||||
templateUrl: './transaction-history.component.html',
|
templateUrl: './transaction-history.component.html',
|
||||||
styleUrl: './transaction-history.component.css',
|
styleUrl: './transaction-history.component.css',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class TransactionHistoryComponent {
|
export class TransactionHistoryComponent {
|
||||||
|
@Input()
|
||||||
|
isOpen: boolean = false;
|
||||||
private transactionService: TransactionService = inject(TransactionService);
|
private transactionService: TransactionService = inject(TransactionService);
|
||||||
|
@Output()
|
||||||
|
closeEventEmitter = new EventEmitter<void>();
|
||||||
|
transactions$: Observable<Transaction[]> = this.transactionService.getUsersTransactions();
|
||||||
|
|
||||||
transactions$: Observable<> = this.transactionService.getUsersTransactions();
|
closeDialog() {
|
||||||
|
this.isOpen = false;
|
||||||
|
this.closeEventEmitter.emit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export interface Transaction {
|
export interface Transaction {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
status: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue