feat(i18n): compute bilingual label on giving/ministry/expense-category lookups

This commit is contained in:
Chris Chen
2026-05-29 22:06:09 -07:00
parent 4bee06addb
commit 4e15e9f630
5 changed files with 24 additions and 9 deletions
@@ -18,6 +18,8 @@ export interface GivingCategoryDto {
description_zh: string | null;
isActive: boolean;
sortOrder: number;
/** Display-only bilingual label, computed in the API service. */
label?: string;
}
export interface CreateGivingCategoryRequest {
name_en: string;
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Observable, map } from 'rxjs';
import { bilingual } from '../../../shared/i18n/bilingual';
import { ApiConfigService } from '../../../core/services/api-config.service';
import {
GivingCategoryDto, CreateGivingCategoryRequest, UpdateGivingCategoryRequest,
@@ -15,7 +16,9 @@ export class GivingCategoryApiService {
getAll(includeInactive = false): Observable<GivingCategoryDto[]> {
const params = new HttpParams().set('includeInactive', includeInactive);
return this.http.get<GivingCategoryDto[]>(this.endpoint, { params });
return this.http.get<GivingCategoryDto[]>(this.endpoint, { params }).pipe(
map(list => list.map(c => ({ ...c, label: bilingual(c.name_en, c.name_zh) }))),
);
}
create(request: CreateGivingCategoryRequest): Observable<{ id: number }> {
return this.http.post<{ id: number }>(this.endpoint, request);