import clsx from "clsx"; import { Fragment } from "react"; import { MediaDto } from "~/application/dtos/entities/MediaDto"; import DownloadIcon from "~/components/ui/icons/DownloadIcon"; export default function RowMediaCell({ media, layout = "table" }: { media: MediaDto[] | undefined; layout?: string }) { const onDownload = (media: MediaDto) => { const downloadLink = document.createElement("a"); downloadLink.href = media.publicUrl ?? media.file; downloadLink.download = media.name; downloadLink.click(); }; function getFileName(name: string) { let fileName = name; if (name.includes("/")) { fileName = name.split("/").pop() ?? name; } if (name.includes("\\")) { fileName = name.split("\\").pop() ?? name; } return fileName; } return (
{media ?.filter((f) => f.type.includes("image")) .map((item) => { return {item.name}; })} {media ?.filter((f) => !f.type.includes("image")) .map((item, idx) => { return ( ); })}
); }