import { FileText, Image, File } from "lucide-react";
export default function AttachmentItem({ attachment }: { attachment: string }) {
return (
{getIcon(attachment)}
{getName(attachment) || "Sans Nom"}
);
}
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 ;
}
};
const getName = (attachment: string) => {
const parts = attachment.replace("pj_doc", "").split("_");
const nameParts = parts.slice(2); // remove the first two parts
return nameParts.join("_");
};