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

Function deleteBookmark

lib/actions.ts:294–324  ·  view source on GitHub ↗
(
  prevState: ActionState | null,
  formData: {
    id: string;
    url: string;
  },
)

Source from the content-addressed store, hash-verified

292}
293
294export async function deleteBookmark(
295 prevState: ActionState | null,
296 formData: {
297 id: string;
298 url: string;
299 },
300): Promise<ActionState> {
301 try {
302 if (!formData) {
303 return { error: "No form data provided" };
304 }
305
306 const id = formData.id;
307 if (!id) {
308 return { error: "No bookmark ID provided" };
309 }
310
311 const url = formData.url;
312
313 await db.delete(bookmarks).where(eq(bookmarks.id, Number(id)));
314
315 revalidatePath("/admin");
316 revalidatePath("/");
317 revalidatePath(`/${encodeURIComponent(url)}`);
318
319 return { success: true };
320 } catch (err) {
321 console.error("Error deleting bookmark:", err);
322 return { error: "Failed to delete bookmark" };
323 }
324}
325
326// Helper function to handle errors
327type ErrorResponse = {

Callers 1

handleDeleteFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected