From e7b72cfdca53aabeacc8d1a16ad360fb65f71361 Mon Sep 17 00:00:00 2001 From: kang Date: Sun, 14 Jun 2026 23:08:51 +0800 Subject: [PATCH] fix(dashboard, settlement): update analytics scope and enhance settlement operations panel Added 'agentNodeId' to the analytics scope in the SiteDashboardConsole for improved data handling. Introduced 'lastPage' calculation in the SettlementOperationsPanel to enhance pagination logic. Updated wallet console to use the TFunction type for better type safety in translation functions. --- src/modules/dashboard/site-dashboard-console.tsx | 1 + src/modules/settlement/settlement-bills-table.tsx | 1 + src/modules/settlement/settlement-operations-panel.tsx | 4 ++++ src/modules/wallet/wallet-console.tsx | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/dashboard/site-dashboard-console.tsx b/src/modules/dashboard/site-dashboard-console.tsx index beb6cb6..57ec288 100644 --- a/src/modules/dashboard/site-dashboard-console.tsx +++ b/src/modules/dashboard/site-dashboard-console.tsx @@ -73,6 +73,7 @@ export function SiteDashboardConsole(): ReactElement { const analyticsScope = useMemo( () => ({ siteCode: site?.code ?? overview?.site_code ?? "", + agentNodeId: undefined, }), [overview?.site_code, site?.code], ); diff --git a/src/modules/settlement/settlement-bills-table.tsx b/src/modules/settlement/settlement-bills-table.tsx index 1a7a0f2..1a48403 100644 --- a/src/modules/settlement/settlement-bills-table.tsx +++ b/src/modules/settlement/settlement-bills-table.tsx @@ -14,6 +14,7 @@ import { formatSettlementPeriodSpan } from "@/lib/agent-settlement-period-range" import { formatSignedSettlementMoney, } from "@/modules/settlement/settlement-signed-money"; +import { formatDashboardMoneyMinor } from "@/modules/dashboard/use-dashboard-analytics"; import { describeBillPaymentDirection, } from "@/modules/settlement/settlement-bill-display"; diff --git a/src/modules/settlement/settlement-operations-panel.tsx b/src/modules/settlement/settlement-operations-panel.tsx index 30cff2a..caf06d2 100644 --- a/src/modules/settlement/settlement-operations-panel.tsx +++ b/src/modules/settlement/settlement-operations-panel.tsx @@ -211,6 +211,7 @@ export function SettlementOperationsPanel({ ); const total = filteredRows.length; + const lastPage = Math.max(1, Math.ceil(total / perPage)); const pageRows = filteredRows.slice((page - 1) * perPage, page * perPage); const operationTypeLabel = (value: OperationTypeFilter): string => { @@ -402,9 +403,12 @@ export function SettlementOperationsPanel({ {!loading && total > 0 ? ( { setPerPage(value); diff --git a/src/modules/wallet/wallet-console.tsx b/src/modules/wallet/wallet-console.tsx index 499197d..a1a13cb 100644 --- a/src/modules/wallet/wallet-console.tsx +++ b/src/modules/wallet/wallet-console.tsx @@ -4,6 +4,7 @@ import { useCallback, useState } from "react"; import { useSearchParams } from "next/navigation"; import { Copy, RotateCcw, Wrench } from "lucide-react"; import { useTranslation } from "react-i18next"; +import type { TFunction } from "i18next"; import { useAsyncEffect } from "@/hooks/use-async-effect"; import { useTranslationRef } from "@/hooks/use-translation-ref"; import { toast } from "sonner"; @@ -114,7 +115,7 @@ function walletTxnBizTypeLabel( bizType: string, ledgerSource: string | null | undefined, t: (key: string) => string, - tSettlement: (key: string, opts?: { defaultValue?: string }) => string, + tSettlement: TFunction<"settlementCenter">, ): string { if (ledgerSource === "credit_ledger") { return creditLedgerReasonLabel(bizType, tSettlement);