Merge pull request 'setup user email' (#34) from mazdak/setup-user-email into dev-pending-01-01-2026
Reviewed-on: https://ct.mfsys.com.pk/aConnect/aConnect-UX/pulls/34mazdak/UX-1985
commit
bcf4b208cc
@ -0,0 +1,28 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { TransactionLog } from '../../models/user';
|
||||
|
||||
@Pipe({
|
||||
name: 'transactionLogFilter',
|
||||
standalone: true
|
||||
})
|
||||
export class TransactionLogFilterPipe implements PipeTransform {
|
||||
transform(logs: TransactionLog[], searchText: string): TransactionLog[] {
|
||||
if (!logs || !searchText) {
|
||||
return logs;
|
||||
}
|
||||
|
||||
const search = searchText.toLowerCase();
|
||||
|
||||
return logs.filter(log =>
|
||||
log.logId?.toString().toLowerCase().includes(search) ||
|
||||
log.porOrgacode?.toLowerCase().includes(search) ||
|
||||
log.transactionID?.toLowerCase().includes(search) ||
|
||||
log.drMbmbkmsnumber?.toLowerCase().includes(search) ||
|
||||
log.crMbmbkmsnumber?.toLowerCase().includes(search) ||
|
||||
log.ppmPymdcode?.toLowerCase().includes(search) ||
|
||||
log.sgtGntrdate?.toLowerCase().includes(search) ||
|
||||
log.channelCode?.toLowerCase().includes(search) ||
|
||||
log.createdAt?.toLowerCase().includes(search)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,24 +1,71 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, map, Observable } from 'rxjs';
|
||||
import { URIKey } from '../../utils/uri-enums';
|
||||
import { HttpErrorResponse, HttpParams } from '@angular/common/http';
|
||||
import { HttpURIService } from '../../app.http.uri.service';
|
||||
import { TransactionLog } from '../../models/user';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TransactionLogService {
|
||||
|
||||
private logsSubject = new BehaviorSubject<TransactionLog[]>([]);
|
||||
private currentPageSubject = new BehaviorSubject<number>(1);
|
||||
private totalCountSubject = new BehaviorSubject<number>(0);
|
||||
private itemsPerPageSubject = new BehaviorSubject<number>(5);
|
||||
|
||||
logs$ = this.logsSubject.asObservable();
|
||||
currentPage$ = this.currentPageSubject.asObservable();
|
||||
totalCount$ = this.totalCountSubject.asObservable();
|
||||
itemsPerPage$ = this.itemsPerPageSubject.asObservable();
|
||||
|
||||
constructor(private httpUriService: HttpURIService) {}
|
||||
|
||||
getTransactionLogs(): Observable<any[]> {
|
||||
loadLogs(): void {
|
||||
const params = new HttpParams();
|
||||
return this.httpUriService.requestGET(URIKey.TRANSACTION_LOGS, params).pipe(map((response: any) => {
|
||||
if (!(response instanceof HttpErrorResponse)) {
|
||||
return Array.isArray(response) ? response : [];
|
||||
this.httpUriService
|
||||
.requestGET<any>(URIKey.TRANSACTION_LOGS, params)
|
||||
.subscribe({
|
||||
next: (res) => {
|
||||
const logs = Array.isArray(res) ? res : res?.data;
|
||||
this.logsSubject.next(logs ?? []);
|
||||
this.totalCountSubject.next(logs.length);
|
||||
},
|
||||
error: (err) => console.error(err)
|
||||
});
|
||||
}
|
||||
return [];
|
||||
})
|
||||
);
|
||||
|
||||
setItemsPerPage(itemsPerPage: number): void {
|
||||
this.itemsPerPageSubject.next(itemsPerPage);
|
||||
this.currentPageSubject.next(1);
|
||||
}
|
||||
|
||||
nextPage(): void {
|
||||
const totalPages = this.getTotalPages();
|
||||
const currentPage = this.currentPageSubject.value;
|
||||
if (currentPage < totalPages) {
|
||||
this.currentPageSubject.next(currentPage + 1);
|
||||
}
|
||||
}
|
||||
|
||||
previousPage(): void {
|
||||
const currentPage = this.currentPageSubject.value;
|
||||
if (currentPage > 1) {
|
||||
this.currentPageSubject.next(currentPage - 1);
|
||||
}
|
||||
}
|
||||
|
||||
goToPage(page: number): void {
|
||||
const totalPages = this.getTotalPages();
|
||||
if (page > 0 && page <= totalPages) {
|
||||
this.currentPageSubject.next(page);
|
||||
}
|
||||
}
|
||||
|
||||
getTotalPages(): number {
|
||||
const totalCount = this.totalCountSubject.value;
|
||||
const itemsPerPage = this.itemsPerPageSubject.value;
|
||||
return Math.ceil(totalCount / itemsPerPage);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue