109 lines
3.1 KiB
TypeScript
109 lines
3.1 KiB
TypeScript
/**
|
|
* 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, inject } from '@angular/core';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import {
|
|
MatTableDataSource,
|
|
MatTable,
|
|
MatColumnDef,
|
|
MatHeaderCellDef,
|
|
MatHeaderCell,
|
|
MatCellDef,
|
|
MatCell,
|
|
MatHeaderRowDef,
|
|
MatHeaderRow,
|
|
MatRowDef,
|
|
MatRow
|
|
} from '@angular/material/table';
|
|
import { MatIcon } from '@angular/material/icon';
|
|
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
|
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
|
|
|
@Component({
|
|
selector: 'mifosx-rejected-account',
|
|
templateUrl: './rejected-account.component.html',
|
|
styleUrls: ['./rejected-account.component.scss'],
|
|
imports: [
|
|
...STANDALONE_SHARED_IMPORTS,
|
|
MatTable,
|
|
MatColumnDef,
|
|
MatHeaderCellDef,
|
|
MatHeaderCell,
|
|
MatCellDef,
|
|
MatCell,
|
|
MatHeaderRowDef,
|
|
MatHeaderRow,
|
|
MatRowDef,
|
|
MatRow,
|
|
MatIcon
|
|
]
|
|
})
|
|
export class RejectedAccountComponent {
|
|
private route = inject(ActivatedRoute);
|
|
private router = inject(Router);
|
|
|
|
dataSource: MatTableDataSource<any>;
|
|
showData = false;
|
|
|
|
displayedColumns: string[] = [
|
|
'accountNo',
|
|
'clientName',
|
|
'productName',
|
|
'accountType',
|
|
'officeName',
|
|
'fieldOfficerName',
|
|
'submittedOnDate',
|
|
'rejectedOnDate',
|
|
'status'
|
|
];
|
|
|
|
constructor() {
|
|
this.route.data.subscribe((data: { rejectedAccountsData: any }) => {
|
|
// status 500 = rejected only; strip out any non-rejected records
|
|
const items = (data.rejectedAccountsData?.pageItems || []).filter((a: any) => a.status?.id === 500);
|
|
this.showData = items.length > 0;
|
|
this.dataSource = new MatTableDataSource(items);
|
|
});
|
|
}
|
|
|
|
navigateToAccount(account: any): void {
|
|
const clientId = account.clientId;
|
|
const accountId = account.id;
|
|
const depositTypeId = account.depositType?.id;
|
|
let path: string;
|
|
if (account.accountType === 'Current') {
|
|
path = `/clients/${clientId}/current-accounts/${accountId}`;
|
|
} else if (depositTypeId === 200) {
|
|
path = `/clients/${clientId}/fixed-deposits-accounts/${accountId}`;
|
|
} else if (depositTypeId === 300) {
|
|
path = `/clients/${clientId}/recurring-deposits-accounts/${accountId}`;
|
|
} else {
|
|
path = `/clients/${clientId}/savings-accounts/${accountId}`;
|
|
}
|
|
this.router.navigate([path]);
|
|
}
|
|
|
|
applyFilter(filterValue: string = '') {
|
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
|
}
|
|
|
|
formatDate(date: any): string {
|
|
if (!date) return '';
|
|
if (Array.isArray(date)) {
|
|
const d = new Date(date[0], date[1] - 1, date[2]);
|
|
return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' });
|
|
}
|
|
const d = new Date(date);
|
|
if (!isNaN(d.getTime())) {
|
|
return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' });
|
|
}
|
|
return date;
|
|
}
|
|
}
|