(e: React.FormEvent)
| 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>, |
nothing calls this directly
no outgoing calls
no test coverage detected