feat(api, agents, i18n): enhance settlement features and multi-language support

Added new types and API functions for settlement period summaries and credit ledgers, improving the management of agent settlements. Updated the admin console to reflect these changes, enhancing user experience with better navigation and data presentation. Additionally, expanded multi-language support by incorporating new translations in English, Nepali, and Chinese for settlement-related terms, ensuring consistency across the platform.
This commit is contained in:
2026-06-05 18:00:59 +08:00
parent 65eaeecf8c
commit af982bb9f7
73 changed files with 4307 additions and 2494 deletions

View File

@@ -0,0 +1,35 @@
export type SettlementPeriodView = "bills" | "ledger";
const VALID_VIEWS: SettlementPeriodView[] = ["bills", "ledger"];
export function settlementCenterListHref(): string {
return "/admin/settlement-center";
}
export function settlementPeriodViewHref(
periodId: number,
view: SettlementPeriodView = "bills",
): string {
return `/admin/settlement-center?period=${periodId}&view=${view}`;
}
export function parseSettlementCenterView(
periodRaw: string | null,
viewRaw: string | null,
): { periodId: number | null; view: SettlementPeriodView } {
const periodId = periodRaw !== null && periodRaw !== "" ? Number(periodRaw) : NaN;
const normalizedView = viewRaw === "reports" ? "bills" : viewRaw;
const view =
normalizedView !== null && VALID_VIEWS.includes(normalizedView as SettlementPeriodView)
? (normalizedView as SettlementPeriodView)
: "bills";
return {
periodId: Number.isInteger(periodId) && periodId > 0 ? periodId : null,
view,
};
}
export function isSettlementPeriodView(value: string): value is SettlementPeriodView {
return VALID_VIEWS.includes(value as SettlementPeriodView);
}