import { Box, Flex, Text } from "@mantine/core";
import { DialogAttachmentProps } from "./DialogAttachment";
import { useRosettaColors } from "@/app/hooks/useRosettaColors";
import { IconFile, IconFileTypeJpg, IconFileTypeJs, IconFileTypePng, IconFileTypeZip, IconX } from "@tabler/icons-react";
import { dotCenterIfNeeded, humanFilesize } from "@/app/utils/utils";
export function AttachFile(props : DialogAttachmentProps) {
const colors = useRosettaColors();
const filesize = parseInt(props.attach.preview.split("::")[0]);
const filename = props.attach.preview.split("::")[1];
const filetype = filename.split(".")[filename.split(".").length - 1];
const getIconByFiletype = (type : string) : React.ReactNode => {
type = type.trim().toLocaleLowerCase();
const iconAttributes = {
size: 23,
color: colors.chevrons.active
}
switch(type){
case 'js':
return
case 'jpeg':
return
case 'jpg':
return
case 'png':
return
case 'zip':
return
case '7z':
return
default:
return
}
}
const icon = getIconByFiletype(filetype);
return (
{icon}
{dotCenterIfNeeded(filename, 10)}
{humanFilesize(filesize)}
{props.onRemove &&
{
props.onRemove && props.onRemove(props.attach);
}}>
}
);
}