Refactor agents console and related components
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
- Simplified share rate calculation in AgentsConsole by removing unnecessary checks and directly setting the profile share rate. - Updated the use of `profileParentCaps` to always return total share rate in the agent profile. - Removed unused variables and memoized calculations for improved performance. - Cleaned up imports in various files, removing unused components and optimizing the code structure. - Added `tRef` dependency to several useEffect hooks to ensure proper reactivity to translation changes. - Enhanced report preview tables with better label handling for various statuses and actions. - Updated wallet filter options to align with player-side transaction types. - Introduced new properties in types for better type safety and clarity.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
@@ -29,7 +28,7 @@ import {
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { AdminLoadingState, AdminLoadingInline, AdminTableLoadingRow } from "@/components/admin/admin-loading-state";
|
||||
import { AdminLoadingState } from "@/components/admin/admin-loading-state";
|
||||
import { ratioToPercentUi } from "@/lib/admin-rate-percent";
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
@@ -94,8 +93,6 @@ type OddsConfigDocScreenProps = {
|
||||
embedded?: boolean;
|
||||
/** 合并页:左侧三步骤 + 右侧配置摘要(参考设计稿) */
|
||||
mergedLayout?: boolean;
|
||||
/** 合并页第 3 步:佣金 / 回水 */
|
||||
rebateSection?: ReactNode;
|
||||
/** 合并页共享数据层(避免与回水区块重复拉取版本详情) */
|
||||
workspace?: OddsConfigWorkspace;
|
||||
/** 与回水分区共用版本选择(无 workspace 时) */
|
||||
@@ -106,7 +103,6 @@ type OddsConfigDocScreenProps = {
|
||||
export function OddsConfigDocScreen({
|
||||
embedded = false,
|
||||
mergedLayout = false,
|
||||
rebateSection,
|
||||
workspace,
|
||||
versionId: controlledVersionId,
|
||||
onVersionIdChange,
|
||||
@@ -159,7 +155,7 @@ export function OddsConfigDocScreen({
|
||||
} finally {
|
||||
setLoadingTypes(false);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
const refreshList = useCallback(async () => {
|
||||
setLoadingList(true);
|
||||
@@ -175,7 +171,7 @@ export function OddsConfigDocScreen({
|
||||
} finally {
|
||||
setLoadingList(false);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useAsyncEffect(() => {
|
||||
if (workspace) {
|
||||
@@ -199,7 +195,7 @@ export function OddsConfigDocScreen({
|
||||
} finally {
|
||||
setLoadingDetail(false);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (workspace) {
|
||||
@@ -492,7 +488,7 @@ export function OddsConfigDocScreen({
|
||||
newValue: next?.odds_value ?? null,
|
||||
};
|
||||
});
|
||||
}, [activeCompareRows, resolvedDetail, resolvedDraftRows, resolvedPlayCode, t, i18n.language]);
|
||||
}, [activeCompareRows, resolvedDetail, resolvedDraftRows, resolvedPlayCode, t]);
|
||||
|
||||
const catTabs: { id: CatTab; label: string }[] = [
|
||||
{ id: "all", label: t("odds.tabs.all", { ns: "config" }) },
|
||||
|
||||
@@ -181,7 +181,7 @@ export function PlayConfigDocScreen() {
|
||||
} finally {
|
||||
setLoadingList(false);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useAsyncEffect(() => {
|
||||
void refreshList();
|
||||
@@ -214,7 +214,7 @@ export function PlayConfigDocScreen() {
|
||||
setLoadingDetail(false);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (list.length === 0) {
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { AdminLoadingState, AdminLoadingInline, AdminTableLoadingRow } from "@/components/admin/admin-loading-state";
|
||||
import { AdminLoadingState } from "@/components/admin/admin-loading-state";
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
|
||||
@@ -133,7 +133,6 @@ export function RebateConfigDocScreen({
|
||||
const resolvedList = workspace?.list ?? listRows;
|
||||
const resolvedDetail = workspace?.detail ?? detail;
|
||||
const resolvedDraftRows = workspace?.draftRows ?? draftRows;
|
||||
const setResolvedDraftRows = workspace?.setDraftRows ?? setDraftRows;
|
||||
const resolvedLoading = workspace ? workspace.loadingList || workspace.loadingTypes : loading;
|
||||
const resolvedLoadingDetail = workspace?.loadingDetail ?? loadingDetail;
|
||||
|
||||
@@ -152,7 +151,7 @@ export function RebateConfigDocScreen({
|
||||
);
|
||||
setTypes([]);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
const refreshList = useCallback(async () => {
|
||||
try {
|
||||
@@ -164,7 +163,7 @@ export function RebateConfigDocScreen({
|
||||
);
|
||||
setListRows([]);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useAsyncEffect(() => {
|
||||
if (workspace) {
|
||||
@@ -239,7 +238,7 @@ export function RebateConfigDocScreen({
|
||||
} finally {
|
||||
setLoadingDetail(false);
|
||||
}
|
||||
}, []);
|
||||
}, [tRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (workspace) {
|
||||
|
||||
Reference in New Issue
Block a user