feat(posts): 类型特殊块移至正文下,采纳答案卡与中奖楼层按评论标记
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
frontend/components/AcceptedAnswerReopen.tsx
Normal file
36
frontend/components/AcceptedAnswerReopen.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { apiReopenQuestion } from "@/lib/api";
|
||||
import { toast } from "@/lib/toast";
|
||||
|
||||
/** 已采纳答案卡上的「重新打开」——并入正文下方资料卡,避免与上方状态条重复 */
|
||||
export default function AcceptedAnswerReopen({ postId }: { postId: number }) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const reopen = async () => {
|
||||
setBusy(true);
|
||||
try {
|
||||
const res = await apiReopenQuestion(String(postId));
|
||||
if (res.post) {
|
||||
toast("已重新打开", "ok");
|
||||
router.refresh();
|
||||
} else toast(res.error || "操作失败", "error");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-line btn-sm shrink-0 ml-auto"
|
||||
disabled={busy}
|
||||
onClick={() => void reopen()}
|
||||
>
|
||||
{busy ? "处理中…" : "重新打开"}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user