'use client';
import { useState } from 'react';
import { CheckCircle, Pin } from 'lucide-react';
import { addPin } from '@/lib/api/pins';
interface PinBadgeProps {
cid: string;
isPinned: boolean;
onPin: (cid: string) => void;
}
export default function PinBadge({ cid, isPinned, onPin }: PinBadgeProps) {
const [pinning, setPinning] = useState(false);
async function handlePin() {
setPinning(true);
try {
await addPin(cid);
onPin(cid);
} catch (err) {
console.error('[PinBadge] Failed to pin CID:', err);
} finally {
setPinning(false);
}
}
if (isPinned) {
return (
Pinned
);
}
return (
);
}