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:
@@ -73,6 +73,7 @@ export function SiteDashboardConsole(): ReactElement {
|
||||
const analyticsScope = useMemo(
|
||||
() => ({
|
||||
siteCode: site?.code ?? overview?.site_code ?? "",
|
||||
agentNodeId: undefined,
|
||||
}),
|
||||
[overview?.site_code, site?.code],
|
||||
);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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 ? (
|
||||
<AdminListPaginationFooter
|
||||
selectId="settlement-operations-per-page"
|
||||
page={page}
|
||||
perPage={perPage}
|
||||
total={total}
|
||||
lastPage={lastPage}
|
||||
loading={loading}
|
||||
onPageChange={setPage}
|
||||
onPerPageChange={(value) => {
|
||||
setPerPage(value);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user