"use client";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
ImageCard,
ImageCardBody,
ImageCardFooter,
ImageCardTitle,
} from "@/components/ui/imageCard";
import { useToast } from "@/components/ui/use-toast";
import APIClient from "@/lib/api";
import { ZBookmarkedLink } from "@/lib/types/api/links";
import { MoreHorizontal, Trash2 } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
export function LinkOptions({ linkId }: { linkId: string }) {
const { toast } = useToast();
const router = useRouter();
const unbookmarkLink = async () => {
let [_, error] = await APIClient.unbookmarkLink(linkId);
if (error) {
toast({
variant: "destructive",
title: "Something went wrong",
description: "There was a problem with your request.",
});
} else {
toast({
description: "The link has been deleted!",
});
}
router.refresh();
};
return (
Delete
);
}
export default function LinkCard({ link }: { link: ZBookmarkedLink }) {
const parsedUrl = new URL(link.url);
return (
{link.details?.title ?? parsedUrl.host}
);
}