feat(settlement, admin): introduce new types and functions for downline share and settlement period hints

Added new types for downline share breakdown and settlement period open hints to enhance the agent settlement API. Updated the admin console components to support these new features, improving the user experience with better data presentation and interaction. Additionally, refined the date range field to accommodate new calendar markers and hints, ensuring a more intuitive interface for managing settlement periods.
This commit is contained in:
2026-06-12 16:01:42 +08:00
parent 1eb6702c51
commit 24fd7c10bd
50 changed files with 1821 additions and 618 deletions

View File

@@ -43,6 +43,7 @@ import { DashboardAnalyticsPanel } from "@/modules/dashboard/dashboard-analytics
import {
formatDashboardCreditMajor,
formatDashboardMoneyMinor,
formatDashboardSignedMoneyMinor,
} from "@/modules/dashboard/use-dashboard-analytics";
import type { AdminDashboardAgentOverview } from "@/types/api/admin-dashboard";
import type { DrawCurrentSnapshot } from "@/types/api/public-draw";
@@ -229,9 +230,9 @@ export function AgentDashboardConsole(): ReactElement {
</p>
</div>
<div className="rounded-2xl border border-white/10 bg-white/8 p-4 backdrop-blur">
<p className="text-xs text-slate-300">{t("agent.todayProfit")}</p>
<p className="text-xs text-slate-300">{t("agent.todayShareProfit")}</p>
<p className="mt-2 text-2xl font-semibold tabular-nums">
{formatDashboardMoneyMinor(overview.today_profit_minor, displayCurrency)}
{formatDashboardSignedMoneyMinor(overview.today_profit_minor, displayCurrency)}
</p>
</div>
</div>
@@ -316,8 +317,8 @@ export function AgentDashboardConsole(): ReactElement {
})}
</p>
<p className="text-xs text-muted-foreground">
{t("agent.sevenDayProfit", {
amount: formatDashboardMoneyMinor(overview.seven_day_profit_minor, displayCurrency),
{t("agent.sevenDayShareProfit", {
amount: formatDashboardSignedMoneyMinor(overview.seven_day_profit_minor, displayCurrency),
})}
</p>
</CardContent>
@@ -384,9 +385,9 @@ export function AgentDashboardConsole(): ReactElement {
{formatDashboardMoneyMinor(overview.top_agent_today.total_bet_minor, displayCurrency)}
</p>
<p className="text-xs text-muted-foreground">
{t("agent.topMomentumHint", {
profit: formatDashboardMoneyMinor(
overview.top_agent_today.approx_house_gross_minor,
{t("agent.topMomentumPayout", {
amount: formatDashboardMoneyMinor(
overview.top_agent_today.total_payout_minor,
displayCurrency,
),
})}

View File

@@ -90,6 +90,7 @@ export function DashboardAnalyticsMain({ analytics }: { analytics: DashboardAnal
sparklines,
formatMoney,
formatSignedMoney,
profitScope,
} = analytics;
if (!enabled) {
@@ -234,14 +235,20 @@ export function DashboardAnalyticsMain({ analytics }: { analytics: DashboardAnal
}
/>
<DashboardKpiCard
label={t("analytics.summaryProfit")}
label={
profitScope === "share_profit"
? t("analytics.summaryShareProfit")
: t("analytics.summaryProfit")
}
value={formatSignedMoney(summary.approx_house_gross_minor, currency)}
hint={
summary.total_bet_minor > 0
? t("marginRate", {
rate: ((summary.approx_house_gross_minor / summary.total_bet_minor) * 100).toFixed(1),
})
: undefined
profitScope === "share_profit"
? t("analytics.shareProfitHint")
: summary.total_bet_minor > 0
? t("marginRate", {
rate: ((summary.approx_house_gross_minor / summary.total_bet_minor) * 100).toFixed(1),
})
: undefined
}
icon={<TrendingUp className="size-4" aria-hidden />}
sparklineValues={sparklines.profit}

View File

@@ -9,9 +9,7 @@ import { buttonVariants } from "@/components/ui/button";
import { AdminNoResourceState } from "@/components/admin/admin-no-resource-state";
import { Card, CardContent } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { formatAdminInstantInTimeZone } from "@/lib/admin-datetime";
import { getAdminRequestLocale } from "@/lib/admin-locale";
import { LOTTERY_SCHEDULE_TIMEZONE } from "@/lib/lottery-schedule-timezone";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { cn } from "@/lib/utils";
import type { DrawCurrentSnapshot } from "@/types/api/public-draw";
@@ -64,11 +62,7 @@ export function DashboardCurrentDrawCard({
loading = false,
}: DashboardCurrentDrawCardProps): ReactElement {
const { t } = useTranslation(["dashboard", "draws"]);
const formatDt = (iso: string | null | undefined): string =>
formatAdminInstantInTimeZone(iso, {
locale: getAdminRequestLocale(),
timeZone: LOTTERY_SCHEDULE_TIMEZONE,
});
const formatDt = useAdminDateTimeFormatter();
if (loading) {
return (

View File

@@ -140,6 +140,7 @@ export function useDashboardAnalytics({
const currency = data?.currency_code ?? null;
const summary = data?.summary;
const profitScope = data?.profit_scope ?? "house_gross";
const periodRangeLabel = useMemo(() => {
if (!data) {
@@ -230,6 +231,7 @@ export function useDashboardAnalytics({
data,
currency,
summary,
profitScope,
periodRangeLabel,
playFilterLabel,
playOptions,