/** * 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, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; /** A single published version of the bank's user agreement/warning text. */ export interface UserAgreement { id: number; version: number; title: string; body: string; isActive?: boolean; createdByUsername?: string; createdOn?: string | number[]; } @Injectable({ providedIn: 'root' }) export class UserAgreementService { private http = inject(HttpClient); /** List all published versions, newest first. */ getAll(): Observable { return this.http.get('/useragreements'); } /** The currently-active version — the one new users must accept. */ getActive(): Observable { return this.http.get('/useragreements/active'); } /** Publish a new version. The backend deactivates the previous active row automatically. */ create(data: { title: string; body: string }): Observable<{ resourceId: number }> { return this.http.post<{ resourceId: number }>('/useragreements', data); } }