MCPcopy Create free account
hub / github.com/9d8dev/directory / AdminPage

Function AdminPage

app/admin/basic/page.tsx:6–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import AdminHeader from "@/components/admin/admin-header";
5
6export default function AdminPage() {
7 const [formData, setFormData] = useState({
8 url: "",
9 slug: "",
10 name: "",
11 description: "",
12 category: "",
13 use_case: "",
14 how_to_use: "",
15 overview: "",
16 screenshot_url: "",
17 });
18
19 const handleSubmit = async (e: React.FormEvent) => {
20 e.preventDefault();
21 try {
22 const response = await fetch("/api/bookmarks", {
23 method: "POST",
24 headers: {
25 "Content-Type": "application/json",
26 },
27 body: JSON.stringify(formData),
28 });
29
30 if (!response.ok) {
31 throw new Error("Failed to add bookmark");
32 }
33
34 // Clear form after successful submission
35 setFormData({
36 url: "",
37 slug: "",
38 name: "",
39 description: "",
40 category: "",
41 use_case: "",
42 how_to_use: "",
43 overview: "",
44 screenshot_url: "",
45 });
46
47 alert("Bookmark added successfully!");
48 } catch (error) {
49 console.error("Error adding bookmark:", error);
50 alert("Failed to add bookmark. Please try again.");
51 }
52 };
53
54 const handleChange = (
55 e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
56 ) => {
57 const { name, value } = e.target;
58 setFormData((prev) => ({ ...prev, [name]: value }));
59 };
60
61 return (
62 <>
63 <AdminHeader />

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected