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:
35
src/modules/settlement/settlement-center-nav.ts
Normal file
35
src/modules/settlement/settlement-center-nav.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user