feat(submission): auto-publish approved submissions and expose review tab
- approving a submission now creates the McpService/McpToolApi records - and records the published service id back on the submission - review console folded into the admin console as a Submissions tab - submit page rewritten around the shared submission API
This commit is contained in:
1 parent
d18adf035b
commit
1fbb6711f2
6 files changed
+517
-77
No files matched your search
@@ -1,55 +1,7 @@
|
||||
"use client";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React from "react";
|
||||
import { SubmissionsManagement } from "@/components/console/SubmissionsManagement";
|
||||
|
||||
export default function AdminSubmissionsPage() {
|
||||
const [list, setList] = useState<any[]>([]);
|
||||
const [status, setStatus] = useState("pending");
|
||||
|
||||
const load = async () => {
|
||||
const res = await fetch(`/api/submission/admin/submissions?status=${status}`, { credentials: "include" });
|
||||
const data = await res.json();
|
||||
setList(data?.data || []);
|
||||
};
|
||||
|
||||
useEffect(() => { load(); }, [status]);
|
||||
|
||||
const approve = async (id: string) => {
|
||||
await fetch(`/api/submission/admin/submission/${id}/approve`, { method: "PUT", credentials: "include" });
|
||||
load();
|
||||
};
|
||||
const reject = async (id: string) => {
|
||||
await fetch(`/api/submission/admin/submission/${id}/reject`, { method: "PUT", credentials: "include", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ note: "rejected" }) });
|
||||
load();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto p-6">
|
||||
<h1 className="text-2xl font-bold mb-4">提交审核</h1>
|
||||
<select value={status} onChange={e => setStatus(e.target.value)} className="border p-2 mb-4">
|
||||
<option value="pending">待审核</option>
|
||||
<option value="approved">已通过</option>
|
||||
<option value="rejected">已拒绝</option>
|
||||
</select>
|
||||
<table className="w-full border">
|
||||
<thead><tr><th>名称</th><th>类型</th><th>状态</th><th>操作</th></tr></thead>
|
||||
<tbody>
|
||||
{list.map((s: any) => (
|
||||
<tr key={s.id} className="border-t">
|
||||
<td className="p-2">{s.name}</td>
|
||||
<td className="p-2">{s.type}</td>
|
||||
<td className="p-2">{s.status}</td>
|
||||
<td className="p-2">
|
||||
{s.status === "pending" && (
|
||||
<>
|
||||
<button onClick={() => approve(s.id)} className="text-green-600 mr-2">通过</button>
|
||||
<button onClick={() => reject(s.id)} className="text-red-600">拒绝</button>
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
return <SubmissionsManagement />;
|
||||
}
|
||||
Reference in new issue
Block a user