feat(admin, players): enhance player management and admin interfaces
Some checks failed
lotteryadmin CI / build (push) Has been cancelled

Updated the player management components to improve error handling and display for various operations, including ticket loading and transaction retrieval. Introduced new status badges for better visual representation of player statuses. Enhanced localization support for error messages and improved the overall user experience in the admin console. Refactored components for better maintainability and clarity.
This commit is contained in:
2026-06-22 10:50:59 +08:00
parent d6c7d2c361
commit c6119da9f8
31 changed files with 777 additions and 463 deletions

View File

@@ -69,7 +69,7 @@ import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { PRD_SETTLEMENT_AGENT_MANAGE, PRD_USERS_MANAGE } from "@/lib/admin-prd";
import { isSiteAdminOperator } from "@/lib/admin-session-variants";
import { settlementBillOperableByBoundAgent } from "@/modules/settlement/settlement-bill-operable";
import { resolveRoleStatusTone } from "@/lib/admin-status-tone";
import { resolvePlayerStatusTone } from "@/lib/admin-status-tone";
import { useAdminProfile } from "@/stores/admin-session";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminPlayerRow } from "@/types/api/admin-player";
@@ -201,6 +201,7 @@ export function AgentsPlayersPanel({
const [total, setTotal] = useState(0);
const [lastPage, setLastPage] = useState(1);
const [loading, setLoading] = useState(true);
const [listErr, setListErr] = useState<string | null>(null);
const [dialogOpen, setDialogOpen] = useState(false);
const [saving, setSaving] = useState(false);
@@ -252,6 +253,7 @@ export function AgentsPlayersPanel({
}
setLoading(true);
setListErr(null);
try {
const data = await getAdminPlayers({
page,
@@ -262,10 +264,11 @@ export function AgentsPlayersPanel({
setItems(data.items);
setTotal(data.meta.total);
setLastPage(Math.max(1, data.meta.last_page));
} catch {
} catch (e) {
setItems([]);
setTotal(0);
setLastPage(1);
setListErr(e instanceof LotteryApiBizError ? e.message : t("common:loadFailed"));
} finally {
setLoading(false);
}
@@ -819,6 +822,9 @@ export function AgentsPlayersPanel({
<AdminLoadingState minHeight="6rem" />
) : (
<>
{listErr ? (
<p className="mb-3 text-sm text-destructive">{listErr}</p>
) : null}
<div className="admin-table-shell overflow-hidden rounded-2xl border border-border/70 bg-card shadow-sm">
<div className="overflow-x-auto">
<Table>
@@ -910,7 +916,7 @@ export function AgentsPlayersPanel({
</TableCell>
{!embedded ? (
<TableCell>
<AdminStatusBadge tone={resolveRoleStatusTone(row.status)}>
<AdminStatusBadge status={row.status} tone={resolvePlayerStatusTone(row.status)}>
{playerStatusLabel(row.status, t)}
</AdminStatusBadge>
</TableCell>