feat(agents, i18n): enhance agent management and settlement features with new translations and UI updates
Added new translations for agent management and settlement features in English, Nepali, and Chinese, improving multi-language support. Updated the agents console to reflect changes in funding modes and player details, enhancing user experience. Refactored the admin permission gate to include new logic for handling bound line agents, ensuring better permission management. Additionally, streamlined the UI for agent-related pages and improved navigation to the settlement center, consolidating related functionalities for better accessibility.
This commit is contained in:
72
src/modules/settlement/agent-settlement-period-select.tsx
Normal file
72
src/modules/settlement/agent-settlement-period-select.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { formatSettlementPeriodSpan } from "@/lib/agent-settlement-period-range";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import type { SettlementPeriodRow } from "@/api/admin-agent-settlement";
|
||||
|
||||
export type AgentSettlementPeriodFilter = number | "all";
|
||||
|
||||
type AgentSettlementPeriodSelectProps = {
|
||||
periods: SettlementPeriodRow[];
|
||||
value: AgentSettlementPeriodFilter;
|
||||
onChange: (value: AgentSettlementPeriodFilter) => void;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function AgentSettlementPeriodSelect({
|
||||
periods,
|
||||
value,
|
||||
onChange,
|
||||
className,
|
||||
}: AgentSettlementPeriodSelectProps): React.ReactElement {
|
||||
const { t } = useTranslation("agents");
|
||||
|
||||
const sorted = [...periods].sort((a, b) => b.id - a.id);
|
||||
|
||||
return (
|
||||
<Select
|
||||
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: "选择账期" })} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">
|
||||
{t("settlementBills.allPeriods", { defaultValue: "全部账期" })}
|
||||
</SelectItem>
|
||||
{sorted.map((row) => (
|
||||
<SelectItem key={row.id} value={String(row.id)}>
|
||||
{formatSettlementPeriodSpan(row.period_start, row.period_end)}
|
||||
{" · "}
|
||||
{periodStatusLabel(row.status, t)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
function periodStatusLabel(
|
||||
status: string,
|
||||
t: (key: string, opts?: { defaultValue?: string }) => string,
|
||||
): string {
|
||||
if (status === "open") {
|
||||
return t("settlementPeriods.statusOpen", { defaultValue: "进行中" });
|
||||
}
|
||||
if (status === "closed") {
|
||||
return t("settlementPeriods.statusClosed", { defaultValue: "已关账" });
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
Reference in New Issue
Block a user