2024-10-18 17:02:42 +02:00
|
|
|
import {
|
|
|
|
|
ButtonIcon,
|
|
|
|
|
Cell,
|
2024-10-21 16:28:16 +02:00
|
|
|
Toast,
|
2024-10-18 17:02:42 +02:00
|
|
|
WebFileIcon,
|
|
|
|
|
} from "@codex-storage/marketplace-ui-components";
|
|
|
|
|
import { CodexDataContent } from "@codex-storage/sdk-js";
|
2024-10-21 16:28:16 +02:00
|
|
|
import { useState } from "react";
|
2024-11-05 09:57:13 +01:00
|
|
|
import "./FileCell.css";
|
2024-11-06 21:11:50 +01:00
|
|
|
import CopyIcon from "../../assets/icons/copy.svg?react";
|
2024-10-18 17:02:42 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
content: CodexDataContent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function FileCell({ content }: Props) {
|
2024-10-21 16:28:16 +02:00
|
|
|
const [toast, setToast] = useState({ time: 0, message: "" });
|
|
|
|
|
|
|
|
|
|
const onCopy = (cid: string) => {
|
|
|
|
|
navigator.clipboard.writeText(cid);
|
|
|
|
|
setToast({ message: "CID copied to the clipboard.", time: Date.now() });
|
|
|
|
|
};
|
2024-10-18 17:02:42 +02:00
|
|
|
|
|
|
|
|
return (
|
2024-10-21 16:28:16 +02:00
|
|
|
<>
|
2024-11-05 09:57:13 +01:00
|
|
|
<Cell className="file-cell">
|
|
|
|
|
<div>
|
2024-11-01 20:23:47 +01:00
|
|
|
<WebFileIcon type={content.manifest.mimetype || ""} />
|
2024-10-18 17:02:42 +02:00
|
|
|
|
|
|
|
|
<div>
|
2024-11-05 09:57:13 +01:00
|
|
|
<p>
|
|
|
|
|
<b>{content.manifest.filename}</b>
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
<small>{content.cid}</small>
|
|
|
|
|
</p>
|
2024-10-18 17:02:42 +02:00
|
|
|
</div>
|
2024-11-05 09:57:13 +01:00
|
|
|
<ButtonIcon
|
|
|
|
|
variant="small"
|
|
|
|
|
onClick={() => onCopy(content.cid)}
|
|
|
|
|
animation="buzz"
|
2024-11-06 21:11:50 +01:00
|
|
|
Icon={(props) => (
|
|
|
|
|
<CopyIcon {...props} width={20} color="#969696" />
|
|
|
|
|
)}></ButtonIcon>
|
2024-10-18 17:02:42 +02:00
|
|
|
</div>
|
2024-10-21 16:28:16 +02:00
|
|
|
|
|
|
|
|
<Toast message={toast.message} time={toast.time} variant={"success"} />
|
|
|
|
|
</Cell>
|
|
|
|
|
</>
|
2024-10-18 17:02:42 +02:00
|
|
|
);
|
|
|
|
|
}
|