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:
51
src/lib/admin-select-display.ts
Normal file
51
src/lib/admin-select-display.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/** Base UI Select 会直接显示 `value`;筛选用哨兵时需手动映射展示文案。 */
|
||||
export const ADMIN_SELECT_FILTER_ALL = "__all__";
|
||||
|
||||
export function isAdminSelectFilterAll(raw: unknown): boolean {
|
||||
const v = raw == null ? "" : String(raw);
|
||||
return v === "" || v === ADMIN_SELECT_FILTER_ALL;
|
||||
}
|
||||
|
||||
export function adminSelectFilterLabel(
|
||||
raw: unknown,
|
||||
allLabel: string,
|
||||
resolveOptionLabel: (value: string) => string,
|
||||
): string {
|
||||
const v = raw == null ? "" : String(raw);
|
||||
if (isAdminSelectFilterAll(v)) {
|
||||
return allLabel;
|
||||
}
|
||||
return resolveOptionLabel(v);
|
||||
}
|
||||
|
||||
export type AdminSiteOption = { code: string; name?: string | null };
|
||||
|
||||
export function adminSiteSelectLabel(
|
||||
raw: unknown,
|
||||
sites: readonly AdminSiteOption[],
|
||||
allLabel: string,
|
||||
): string {
|
||||
return adminSelectFilterLabel(raw, allLabel, (code) => {
|
||||
const site = sites.find((s) => s.code === code);
|
||||
if (!site) {
|
||||
return code;
|
||||
}
|
||||
return site.name ? `${site.name} (${site.code})` : site.code;
|
||||
});
|
||||
}
|
||||
|
||||
export function adminSiteCodeLabel(
|
||||
raw: unknown,
|
||||
sites: readonly AdminSiteOption[],
|
||||
placeholder: string,
|
||||
): string {
|
||||
const v = raw == null ? "" : String(raw);
|
||||
if (v === "") {
|
||||
return placeholder;
|
||||
}
|
||||
const site = sites.find((s) => s.code === v);
|
||||
if (!site) {
|
||||
return v;
|
||||
}
|
||||
return site.name ? `${site.name} (${site.code})` : site.code;
|
||||
}
|
||||
Reference in New Issue
Block a user