import { FileText, Image, File } from "lucide-react";
import type { Attachment } from "~/lib/api";
export default function AttachmentItem({ attachment }: { attachment: Attachment }) {
return (
{getIcon(attachment.name)}
{attachment.name}
);
}
const getType = (attachment: string) => {
const ext = attachment.split(".").pop();
if (ext === "pdf") {
return "pdf";
} else if (["jpg", "jpeg", "png", "gif"].includes(ext!)) {
return "image";
} else {
console.error(`Unknown attachment type: ${ext}`);
return "other";
}
};
const getIcon = (attachment: string) => {
switch (getType(attachment)) {
case "pdf":
return ;
case "image":
return ;
// case "document":
// return
// case "spreadsheet":
// return
// case "code":
// return
default:
return ;
}
};