"use client"; import { useTranslation } from "react-i18next"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { formatAdminCreditMajorDecimal } from "@/lib/money"; import { cn } from "@/lib/utils"; import type { AgentParentCaps } from "@/types/api/admin-agent"; export type AgentProfileFieldsProps = { disabled?: boolean; loading?: boolean; parentCaps: AgentParentCaps | null; availableCredit: number | null; canCreateChildAgent: boolean; isSuperAdmin: boolean; shareRate: string; onShareRateChange: (value: string) => void; creditLimit: string; onCreditLimitChange: (value: string) => void; rebateLimit: string; onRebateLimitChange: (value: string) => void; defaultRebate: string; onDefaultRebateChange: (value: string) => void; settlementCycle: "daily" | "weekly" | "monthly"; onSettlementCycleChange: (value: "daily" | "weekly" | "monthly") => void; extraRebate: boolean; onExtraRebateChange: (value: boolean) => void; canCreatePlayer: boolean; onCanCreatePlayerChange: (value: boolean) => void; canCreateChild: boolean; onCanCreateChildChange: (value: boolean) => void; riskTags: string; onRiskTagsChange: (value: string) => void; idPrefix?: string; currencyCode?: string; /** card:用于代理线路详情 Tab 内的卡片表单 */ variant?: "default" | "card"; }; export function AgentProfileFields({ disabled = false, loading = false, parentCaps, availableCredit, canCreateChildAgent, isSuperAdmin, shareRate, onShareRateChange, creditLimit, onCreditLimitChange, rebateLimit, onRebateLimitChange, defaultRebate, onDefaultRebateChange, settlementCycle, onSettlementCycleChange, extraRebate, onExtraRebateChange, canCreatePlayer, onCanCreatePlayerChange, canCreateChild, onCanCreateChildChange, riskTags, onRiskTagsChange, idPrefix = "agent-profile", currencyCode = "NPR", variant = "default", }: AgentProfileFieldsProps): React.ReactElement { const { t } = useTranslation(["agents", "common"]); const fieldDisabled = disabled || loading; const isCard = variant === "card"; return (
{(parentCaps || availableCredit !== null) && !loading ? (
{parentCaps ? (

{t("profile.parentCaps", { defaultValue: "上级占成 {{share}}%,可下发额度 {{credit}}", share: parentCaps.total_share_rate, credit: formatAdminCreditMajorDecimal(parentCaps.available_credit, currencyCode), })}

) : null} {availableCredit !== null ? (

{t("profile.availableCredit", { defaultValue: "可下发额度:{{amount}}", amount: formatAdminCreditMajorDecimal(availableCredit, currencyCode), })}

) : null}
) : null} {loading ? (

{t("profile.loading", { defaultValue: "正在加载占成与授信…" })}

) : null}
onShareRateChange(e.target.value)} />
onCreditLimitChange(e.target.value)} />
onRebateLimitChange(e.target.value)} placeholder="0.5" />
onDefaultRebateChange(e.target.value)} placeholder="0.5" />
onRiskTagsChange(e.target.value)} placeholder={t("profile.riskTagsPlaceholder", { defaultValue: "逗号分隔,如 overdue, high_turnover", })} />
{!isCard ? (

{t("profile.capabilityHint", { defaultValue: "保存后约束该代理主账号能否开玩家/下级;与平台「代理」角色叠加,以本开关为准。", })}

) : null}
); } function SwitchRow({ checked, onCheckedChange, label, disabled = false, }: { checked: boolean; onCheckedChange: (value: boolean) => void; label: string; disabled?: boolean; }): React.ReactElement { return (
); }