refactor: remove unused admin user update function and update related components to use new API
This commit is contained in:
@@ -42,11 +42,3 @@ export async function postAdminLogin(
|
||||
export async function getAdminMe(): Promise<AdminAuthMeResponse> {
|
||||
return adminRequest.get<AdminAuthMeResponse>(`${API_V1_PREFIX}/admin/auth/me`);
|
||||
}
|
||||
|
||||
/** `PUT /api/v1/admin/auth/me`(更新自身账号信息,需 Token) */
|
||||
export async function putAdminMe(body: {
|
||||
nickname?: string;
|
||||
password?: string;
|
||||
}): Promise<AdminAuthMeResponse> {
|
||||
return adminRequest.put<AdminAuthMeResponse>(`${API_V1_PREFIX}/admin/auth/me`, body);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
import { putAdminMe } from "@/api/admin-auth";
|
||||
import { putAdminUser } from "@/api/admin-users";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -35,9 +35,13 @@ export function AccountSettingsConsole() {
|
||||
toast.error(t("validation.required", { field: t("fields.nickname") }));
|
||||
return;
|
||||
}
|
||||
if (!adminProfile) {
|
||||
toast.error(t("actions.updateFailed"));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
await putAdminMe({ nickname: nickname.trim() });
|
||||
await putAdminUser(adminProfile.id, { nickname: nickname.trim() });
|
||||
toast.success(t("actions.updateSuccess"));
|
||||
void refreshAdminProfile();
|
||||
} catch (err) {
|
||||
@@ -56,9 +60,13 @@ export function AccountSettingsConsole() {
|
||||
toast.error(t("validation.passwordMismatch"));
|
||||
return;
|
||||
}
|
||||
if (!adminProfile) {
|
||||
toast.error(t("actions.updateFailed"));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
await putAdminMe({ password });
|
||||
await putAdminUser(adminProfile.id, { password });
|
||||
toast.success(t("actions.updateSuccess"));
|
||||
setPassword("");
|
||||
setConfirmPassword("");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactElement } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactElement, type ReactNode } from "react";
|
||||
import { format, subDays } from "date-fns";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { BarChart3, Gift, TrendingUp, Wallet } from "lucide-react";
|
||||
@@ -77,7 +77,7 @@ export function DashboardAnalyticsPanel({
|
||||
}: {
|
||||
enabled: boolean;
|
||||
playOptions: { code: string; label: string }[];
|
||||
}): ReactElement {
|
||||
}): ReactNode {
|
||||
const { t } = useTranslation(["dashboard", "common"]);
|
||||
const playLabel = useAdminPlayCodeLabel();
|
||||
|
||||
@@ -240,7 +240,7 @@ export function DashboardAnalyticsPanel({
|
||||
<Label className="text-xs text-muted-foreground">{t("analytics.playLabel")}</Label>
|
||||
<Select
|
||||
value={playCode === "" ? "__all__" : playCode}
|
||||
onValueChange={(v) => setPlayCode(v === "__all__" ? "" : v)}
|
||||
onValueChange={(v) => setPlayCode(!v || v === "__all__" ? "" : v)}
|
||||
>
|
||||
<SelectTrigger className="w-full min-w-[160px]">
|
||||
<SelectValue>{playFilterLabel}</SelectValue>
|
||||
|
||||
@@ -304,7 +304,11 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
disabled={acting !== null || summary.status !== "approved"}
|
||||
disabled={
|
||||
acting !== null
|
||||
|| summary.status !== "approved"
|
||||
|| summary.review_status !== "approved"
|
||||
}
|
||||
onClick={() => openActionDialog("payout")}
|
||||
>
|
||||
{t("runPayout")}
|
||||
|
||||
@@ -321,7 +321,11 @@ export function SettlementBatchesConsole() {
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
disabled={actingId !== null || row.status !== "approved"}
|
||||
disabled={
|
||||
actingId !== null
|
||||
|| row.status !== "approved"
|
||||
|| row.review_status !== "approved"
|
||||
}
|
||||
onClick={() => openActionDialog(row, "payout")}
|
||||
>
|
||||
{t("payout")}
|
||||
|
||||
Reference in New Issue
Block a user