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.
This commit is contained in:
2026-06-14 23:08:51 +08:00
parent 6395fcd391
commit e7b72cfdca
4 changed files with 8 additions and 1 deletions

View File

@@ -73,6 +73,7 @@ export function SiteDashboardConsole(): ReactElement {
const analyticsScope = useMemo( const analyticsScope = useMemo(
() => ({ () => ({
siteCode: site?.code ?? overview?.site_code ?? "", siteCode: site?.code ?? overview?.site_code ?? "",
agentNodeId: undefined,
}), }),
[overview?.site_code, site?.code], [overview?.site_code, site?.code],
); );

View File

@@ -14,6 +14,7 @@ import { formatSettlementPeriodSpan } from "@/lib/agent-settlement-period-range"
import { import {
formatSignedSettlementMoney, formatSignedSettlementMoney,
} from "@/modules/settlement/settlement-signed-money"; } from "@/modules/settlement/settlement-signed-money";
import { formatDashboardMoneyMinor } from "@/modules/dashboard/use-dashboard-analytics";
import { import {
describeBillPaymentDirection, describeBillPaymentDirection,
} from "@/modules/settlement/settlement-bill-display"; } from "@/modules/settlement/settlement-bill-display";

View File

@@ -211,6 +211,7 @@ export function SettlementOperationsPanel({
); );
const total = filteredRows.length; const total = filteredRows.length;
const lastPage = Math.max(1, Math.ceil(total / perPage));
const pageRows = filteredRows.slice((page - 1) * perPage, page * perPage); const pageRows = filteredRows.slice((page - 1) * perPage, page * perPage);
const operationTypeLabel = (value: OperationTypeFilter): string => { const operationTypeLabel = (value: OperationTypeFilter): string => {
@@ -402,9 +403,12 @@ export function SettlementOperationsPanel({
{!loading && total > 0 ? ( {!loading && total > 0 ? (
<AdminListPaginationFooter <AdminListPaginationFooter
selectId="settlement-operations-per-page"
page={page} page={page}
perPage={perPage} perPage={perPage}
total={total} total={total}
lastPage={lastPage}
loading={loading}
onPageChange={setPage} onPageChange={setPage}
onPerPageChange={(value) => { onPerPageChange={(value) => {
setPerPage(value); setPerPage(value);

View File

@@ -4,6 +4,7 @@ import { useCallback, useState } from "react";
import { useSearchParams } from "next/navigation"; import { useSearchParams } from "next/navigation";
import { Copy, RotateCcw, Wrench } from "lucide-react"; import { Copy, RotateCcw, Wrench } from "lucide-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import type { TFunction } from "i18next";
import { useAsyncEffect } from "@/hooks/use-async-effect"; import { useAsyncEffect } from "@/hooks/use-async-effect";
import { useTranslationRef } from "@/hooks/use-translation-ref"; import { useTranslationRef } from "@/hooks/use-translation-ref";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -114,7 +115,7 @@ function walletTxnBizTypeLabel(
bizType: string, bizType: string,
ledgerSource: string | null | undefined, ledgerSource: string | null | undefined,
t: (key: string) => string, t: (key: string) => string,
tSettlement: (key: string, opts?: { defaultValue?: string }) => string, tSettlement: TFunction<"settlementCenter">,
): string { ): string {
if (ledgerSource === "credit_ledger") { if (ledgerSource === "credit_ledger") {
return creditLedgerReasonLabel(bizType, tSettlement); return creditLedgerReasonLabel(bizType, tSettlement);