feat(api, i18n): add agent_node_id to various admin queries and enhance multi-language support
Introduced the agent_node_id field in AdminDrawListQuery, AdminPlayerListQuery, AdminSettlementBatchListQuery, TicketItemsListQuery, and TransferOrderListQuery to improve filtering capabilities. Updated the admin-breadcrumb and admin-sidebar components to include new translations for agent-related terms in English, Nepali, and Chinese, enhancing the overall user experience and multi-language support across the admin interface.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAsyncEffect } from "@/hooks/use-async-effect";
|
||||
import { useTranslationRef } from "@/hooks/use-translation-ref";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { getAdminDraws } from "@/api/admin-draws";
|
||||
@@ -26,6 +28,7 @@ import {
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { AdminLoadingState, AdminLoadingInline, AdminTableLoadingRow } from "@/components/admin/admin-loading-state";
|
||||
import { ConfigSection } from "@/modules/config/config-section";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -37,6 +40,7 @@ type PoolFilter = "all" | "sold_out" | "high_risk";
|
||||
|
||||
export function RiskCapRuntimePanel() {
|
||||
const { t } = useTranslation(["config", "risk", "draws", "common"]);
|
||||
const tRef = useTranslationRef(["config", "common"]);
|
||||
const [draws, setDraws] = useState<AdminDrawListItem[]>([]);
|
||||
const [drawsLoading, setDrawsLoading] = useState(true);
|
||||
const [drawId, setDrawId] = useState<string>("");
|
||||
@@ -64,12 +68,14 @@ export function RiskCapRuntimePanel() {
|
||||
setDrawId((prev) => (prev === "" ? String(data.items[0].id) : prev));
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error(e instanceof LotteryApiBizError ? e.message : t("errors.loadFailed", { ns: "common" }));
|
||||
toast.error(
|
||||
e instanceof LotteryApiBizError ? e.message : tRef.current("errors.loadFailed", { ns: "common" }),
|
||||
);
|
||||
setDraws([]);
|
||||
} finally {
|
||||
setDrawsLoading(false);
|
||||
}
|
||||
}, [t]);
|
||||
}, []);
|
||||
|
||||
const loadPools = useCallback(async () => {
|
||||
if (!drawId) {
|
||||
@@ -94,24 +100,22 @@ export function RiskCapRuntimePanel() {
|
||||
setPools(data.items);
|
||||
setCurrencyCode(data.currency_code);
|
||||
} catch (e) {
|
||||
setPoolsError(e instanceof LotteryApiBizError ? e.message : t("errors.loadFailed", { ns: "common" }));
|
||||
setPoolsError(
|
||||
e instanceof LotteryApiBizError ? e.message : tRef.current("errors.loadFailed", { ns: "common" }),
|
||||
);
|
||||
setPools([]);
|
||||
} finally {
|
||||
setPoolsLoading(false);
|
||||
}
|
||||
}, [appliedNumber, drawId, poolFilter, t]);
|
||||
}, [appliedNumber, drawId, poolFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
void loadDraws();
|
||||
});
|
||||
}, [loadDraws]);
|
||||
useAsyncEffect(() => {
|
||||
void loadDraws();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
void loadPools();
|
||||
});
|
||||
}, [loadPools]);
|
||||
useAsyncEffect(() => {
|
||||
void loadPools();
|
||||
}, [appliedNumber, drawId, poolFilter]);
|
||||
|
||||
const riskBase = drawId ? `/admin/draws/${drawId}/risk` : null;
|
||||
|
||||
@@ -226,11 +230,7 @@ export function RiskCapRuntimePanel() {
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{poolsLoading ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="text-muted-foreground">
|
||||
{t("states.loading", { ns: "common" })}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<AdminTableLoadingRow colSpan={5} />
|
||||
) : pools.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user