/** * 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 { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; export interface ClerkSavedAccount { accountDetails: any; clientDetails: any; kycDetails: any; nominees: any[]; jointHolders: any[]; clientAddresses: any[]; nonPersonDetails: any; clientPhotoUrl: string | null; signatureUrl: string | null; accountNotes: any[]; standingInstructions: any[]; todayTransactions: any[]; linkedAccounts: any; sameDayNeftRtgs: number; sameDayChequeClearing: number; selectedRow: any; } export interface ClerkUiState { accountLoaded: boolean; facilities: { label: string; active: boolean }[]; savedRow: { acNo: string; acTyp: string } | null; savedAccount: ClerkSavedAccount | null; } @Injectable({ providedIn: 'root' }) export class ClerkUiStateService { private readonly _state = new BehaviorSubject({ accountLoaded: false, facilities: [], savedRow: null, savedAccount: null }); readonly state$ = this._state.asObservable(); get snapshot(): ClerkUiState { return this._state.value; } setFacilities(facilities: { label: string; active: boolean }[], acNo: string, acTyp: string): void { this._state.next({ ...this._state.value, accountLoaded: true, facilities, savedRow: { acNo, acTyp } }); } saveFullState(account: ClerkSavedAccount): void { this._state.next({ ...this._state.value, savedAccount: account }); } clear(): void { this._state.next({ accountLoaded: false, facilities: [], savedRow: null, savedAccount: null }); } }