fix: ToolFileInput.tsx

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-25 09:46:09 +01:00
parent 9f2dd774e7
commit 1e68c7105f

View File

@@ -26,12 +26,17 @@ export default function ToolFileInput({
const fileInputRef = useRef<HTMLInputElement>(null);
const handleCopy = () => {
navigator.clipboard
.writeText(value?.name ?? '')
.then(() => showSnackBar('Text copied', 'success'))
.catch((err) => {
showSnackBar('Failed to copy: ' + err, 'error');
});
if (value) {
const blob = new Blob([value], { type: value.type });
const clipboardItem = new ClipboardItem({ [value.type]: blob });
navigator.clipboard
.write([clipboardItem])
.then(() => showSnackBar('File copied', 'success'))
.catch((err) => {
showSnackBar('Failed to copy: ' + err, 'error');
});
}
};
useEffect(() => {
if (value) {