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

@@ -27,23 +27,43 @@ export function AgentSettlementPeriodSelect({
onChange,
className,
}: AgentSettlementPeriodSelectProps): React.ReactElement {
const { t } = useTranslation("agents");
const { t } = useTranslation(["agents", "settlementCenter"]);
const sorted = [...periods].sort((a, b) => b.id - a.id);
const periodLabel = (filter: AgentSettlementPeriodFilter): string => {
if (filter === "all") {
return t("settlementCenter:filters.allPeriods", {
defaultValue: t("agents:settlementBills.allPeriods", { defaultValue: "全部账期" }),
});
}
const row = periods.find((p) => p.id === filter);
if (!row) {
return t("agents:settlementBills.periodPlaceholder", { defaultValue: "选择账期" });
}
return `${formatSettlementPeriodSpan(row.period_start, row.period_end)} · ${periodStatusLabel(row.status, t)}`;
};
return (
<Select
modal={false}
value={value === "all" ? "all" : String(value)}
onValueChange={(next) => {
onChange(next === "all" ? "all" : Number(next));
}}
>
<SelectTrigger className={className ?? "h-9 w-full max-w-md"}>
<SelectValue placeholder={t("settlementBills.periodPlaceholder", { defaultValue: "选择账期" })} />
<SelectValue placeholder={t("agents:settlementBills.periodPlaceholder", { defaultValue: "选择账期" })}>
{() => periodLabel(value)}
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem value="all">
{t("settlementBills.allPeriods", { defaultValue: "全部账期" })}
{t("settlementCenter:filters.allPeriods", {
defaultValue: t("agents:settlementBills.allPeriods", { defaultValue: "全部账期" }),
})}
</SelectItem>
{sorted.map((row) => (
<SelectItem key={row.id} value={String(row.id)}>
@@ -62,10 +82,13 @@ function periodStatusLabel(
t: (key: string, opts?: { defaultValue?: string }) => string,
): string {
if (status === "open") {
return t("settlementPeriods.statusOpen", { defaultValue: "进行中" });
return t("agents:settlementPeriods.statusOpen", { defaultValue: "进行中" });
}
if (status === "closed") {
return t("settlementPeriods.statusClosed", { defaultValue: "已关账" });
return t("agents:settlementPeriods.statusClosed", { defaultValue: "已关账" });
}
if (status === "completed") {
return t("settlementCenter:filters.statusCompleted", { defaultValue: "已结清" });
}
return status;