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