added copy shortlink option to dropdown
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
<SMButton
|
<SMButton
|
||||||
label="Edit"
|
label="Edit"
|
||||||
:dropdown="{
|
:dropdown="{
|
||||||
|
copy: 'Copy Shortlink',
|
||||||
delete: 'Delete',
|
delete: 'Delete',
|
||||||
}"
|
}"
|
||||||
size="medium"
|
size="medium"
|
||||||
@@ -111,6 +112,8 @@ const handleSearch = () => {
|
|||||||
const handleActionButton = (item: Shortlink, option: string): void => {
|
const handleActionButton = (item: Shortlink, option: string): void => {
|
||||||
if (option.length == 0) {
|
if (option.length == 0) {
|
||||||
handleEdit(item);
|
handleEdit(item);
|
||||||
|
} else if (option.toLowerCase() == "copy") {
|
||||||
|
handleCopy(item);
|
||||||
} else if (option.toLowerCase() == "delete") {
|
} else if (option.toLowerCase() == "delete") {
|
||||||
handleDelete(item);
|
handleDelete(item);
|
||||||
}
|
}
|
||||||
@@ -163,6 +166,25 @@ const handleEdit = (shortlink: Shortlink) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopy = (shortlink: Shortlink) => {
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(`https://stemmech.com.au/${shortlink.code}`)
|
||||||
|
.then(() => {
|
||||||
|
useToastStore().addToast({
|
||||||
|
title: "Copied to Clipboard",
|
||||||
|
content: "The shortlink URL has been copied to the clipboard.",
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
useToastStore().addToast({
|
||||||
|
title: "Copy to Clipboard",
|
||||||
|
content: "Failed to copy the shortlink URL to the clipboard.",
|
||||||
|
type: "danger",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleDelete = async (shortlink: Shortlink) => {
|
const handleDelete = async (shortlink: Shortlink) => {
|
||||||
let result = await openDialog(DialogConfirm, {
|
let result = await openDialog(DialogConfirm, {
|
||||||
title: "Delete User?",
|
title: "Delete User?",
|
||||||
|
|||||||
Reference in New Issue
Block a user