copy mac fixed

This commit is contained in:
2024-10-30 19:16:32 +05:30
parent 949ff91d26
commit bdf71c55d1
2 changed files with 99 additions and 20 deletions

View File

@@ -83,19 +83,55 @@ const LatestTransactions = () => {
setTotalItems(transCount?.data?.transactionCount);
}, [transCount]);
// function copyToClipboard(text) {
// navigator.clipboard
// .writeText(text)
// .then(() => {
// toast({
// render: () => (
// <ToastBox status={"warn"} message={"Text copied to clipboard"} />
// ),
// });
// })
// .catch((err) => {
// console.error("Failed to copy text: ", err);
// });
// }
function copyToClipboard(text) {
navigator.clipboard
.writeText(text)
.then(() => {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard
.writeText(text)
.then(() => {
toast({
render: () => (
<ToastBox status={"warn"} message={"Text copied to clipboard"} />
),
});
})
.catch((err) => {
console.error("Failed to copy text: ", err);
});
} else {
// Fallback method for unsupported browsers
const textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand("copy");
toast({
render: () => (
<ToastBox status={"warn"} message={"Text copied to clipboard"} />
),
});
})
.catch((err) => {
console.error("Failed to copy text: ", err);
});
} catch (err) {
console.error("Fallback: Failed to copy text: ", err);
}
document.body.removeChild(textArea);
}
}
const handleRefreshClick = () => {