Updated the agent dashboard to include new metrics for today's bets and payouts, improving visibility for users. Enhanced localization files with additional hints and labels for better user experience across English, Nepali, and Chinese. Introduced new functions for formatting business dates and improved the handling of analytics permissions in the dashboard components.
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
"use client";
|
|
|
|
import type { ReactElement, ReactNode } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
/** 盈亏 / 输赢:负红、正绿、零灰 */
|
|
export function signedMoneyClass(amount: number, emphasize = false): string {
|
|
if (amount < 0) {
|
|
return cn("text-destructive", emphasize && "font-semibold");
|
|
}
|
|
if (amount > 0) {
|
|
return cn("text-emerald-600 dark:text-emerald-400", emphasize && "font-semibold");
|
|
}
|
|
|
|
return cn("text-muted-foreground", emphasize && "font-medium");
|
|
}
|
|
|
|
/** 环比趋势色:升/降何者为「好」因指标而异 */
|
|
export function signedTrendClassName(
|
|
series: number[],
|
|
mode: "higherBetter" | "lowerBetter" | "signed",
|
|
): string {
|
|
if (series.length < 2) {
|
|
return "text-muted-foreground";
|
|
}
|
|
const last = series[series.length - 1] ?? 0;
|
|
const prev = series[series.length - 2] ?? 0;
|
|
if (mode === "signed") {
|
|
return signedMoneyClass(last - prev, false);
|
|
}
|
|
const improved = mode === "higherBetter" ? last > prev : last < prev;
|
|
if (last === prev) {
|
|
return "text-muted-foreground";
|
|
}
|
|
return improved
|
|
? "text-emerald-600 dark:text-emerald-400"
|
|
: "text-destructive";
|
|
}
|
|
|
|
export function SignedMoney({
|
|
amount,
|
|
children,
|
|
emphasize,
|
|
className,
|
|
}: {
|
|
amount: number;
|
|
children: ReactNode;
|
|
emphasize?: boolean;
|
|
className?: string;
|
|
}): ReactElement {
|
|
return (
|
|
<span className={cn(signedMoneyClass(amount, emphasize), "tabular-nums", className)}>
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
/** 报表 / 结算字段是否应按正负着色 */
|
|
export function isSignedMoneyField(key: string): boolean {
|
|
return (
|
|
key === "approx_house_gross_minor" ||
|
|
key === "net_win_loss_minor" ||
|
|
key === "gross_win_loss" ||
|
|
key === "game_win_loss" ||
|
|
key === "profit_loss_minor" ||
|
|
key === "today_profit_minor" ||
|
|
key === "seven_day_profit_minor" ||
|
|
key === "platform_profit" ||
|
|
key === "platform_profit_minor" ||
|
|
key === "share_profit" ||
|
|
key === "share_profit_meta" ||
|
|
key.endsWith("_profit_minor")
|
|
);
|
|
}
|