Skip to content

Commit

Permalink
Added the function for copying short-url to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Tveito committed Oct 28, 2024
1 parent 2f13785 commit 6067c53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/ShortLinks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type ShortLinkItemProps = {
const ShortLinkItem = ({ shortLink }: ShortLinkItemProps) => {
const deleteShortLink = useDeleteShortLink();
const { event } = useAnalytics();
const clip = () => {
navigator.clipboard.writeText(`https://s.tihlde.org/${shortLink.name}`);
toast.success('Lenken ble kopiert til utklippstavlen');
};
const { share } = useShare(
{
title: shortLink.name,
Expand All @@ -52,7 +56,7 @@ const ShortLinkItem = ({ shortLink }: ShortLinkItemProps) => {
<CardHeader className='flex flex-row items-center justify-between'>
<CardTitle>{shortLink.name}</CardTitle>
<div>
<Button onClick={share} size='icon' variant='ghost'>
<Button onClick={clip} size='icon' variant='ghost'>
<Copy />
</Button>
<Button onClick={share} size='icon' variant='ghost'>
Expand Down

0 comments on commit 6067c53

Please sign in to comment.