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

Function handleSubmit

app/admin/basic/page.tsx:19–52  ·  view source on GitHub ↗
(e: React.FormEvent)

Source from the content-addressed store, hash-verified

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>,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected