import { FileIcon, X, Plus, ExternalLink } from "lucide-react"; import { openPath } from "@tauri-apps/plugin-opener"; import { open } from "@tauri-apps/plugin-dialog"; import { Button } from "@/components/ui/button"; import { useBoardStore } from "@/stores/board-store"; import { copyAttachment } from "@/lib/storage"; import type { Attachment } from "@/types/board"; interface AttachmentSectionProps { cardId: string; attachments: Attachment[]; } export function AttachmentSection({ cardId, attachments, }: AttachmentSectionProps) { const addAttachment = useBoardStore((s) => s.addAttachment); const removeAttachment = useBoardStore((s) => s.removeAttachment); async function handleAdd() { const selected = await open({ multiple: false, title: "Select attachment", }); if (!selected) return; const fileName = selected.split(/[\\/]/).pop() ?? "attachment"; const board = useBoardStore.getState().board; if (!board) return; const mode = board.settings.attachmentMode; if (mode === "copy") { const destPath = await copyAttachment(board.id, selected, fileName); addAttachment(cardId, { name: fileName, path: destPath, mode: "copy" }); } else { addAttachment(cardId, { name: fileName, path: selected, mode: "link" }); } } return (
{/* Header */}

Attachments

{/* Attachment list */} {attachments.length > 0 ? (
{attachments.map((att) => (
{att.name}
))}
) : (

No attachments

)}
); }