/** * Copyright since 2025 Mifos Initiative * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Component, OnInit, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { MatPaginatorModule, PageEvent } from '@angular/material/paginator'; import { CashierService } from '../cashier.service'; /** Lists recorded cash exchanges (Currency Exchange Detail). */ @Component({ selector: 'mifosx-currency-exchange-detail', templateUrl: './currency-exchange-detail.component.html', styleUrls: ['../cashier-shared.scss'], standalone: true, imports: [ CommonModule, RouterLink, MatIconModule, MatPaginatorModule ] }) export class CurrencyExchangeDetailComponent implements OnInit { private service = inject(CashierService); exchanges: any[] = []; totalRecords = 0; pageSize = 20; pageIndex = 0; pageSizeOptions = [ 10, 20, 50, 100 ]; loading = true; ngOnInit(): void { this.load(); } load(): void { this.loading = true; this.service.getCashExchanges(this.pageIndex * this.pageSize, this.pageSize).subscribe({ next: (res: any) => { this.exchanges = res.pageItems ?? []; this.totalRecords = res.totalFilteredRecords ?? 0; this.loading = false; }, error: () => { this.exchanges = []; this.totalRecords = 0; this.loading = false; } }); } onPageChange(event: PageEvent): void { this.pageIndex = event.pageIndex; this.pageSize = event.pageSize; this.load(); } }