✍ added copy button for notes link

This commit is contained in:
Chirag Bhalotia 2023-06-24 21:07:55 +05:30
parent 13aa51dc9c
commit 13d3679020
No known key found for this signature in database
GPG Key ID: F7F1F1FBFFD40427
1 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import Button from '@/components/ui/Button';
import Cookies from 'js-cookie';
import { ArrowUpRight, Edit, Trash2 } from 'lucide-react';
import { ArrowUpRight, Copy, Edit, Trash2 } from 'lucide-react';
import Link from 'next/link';
import { useEffect, useState } from 'react';
@ -10,10 +10,9 @@ interface NotesLitsProps {
}
function NotesList({ data, onDeleteNote }: NotesLitsProps) {
const [instanceUrl, setInstanceURL] = useState('');
useEffect(() => {
setInstanceURL(Cookies.get('instanceUrl') ?? '');
}, []);
function copyNoteLink(id: string) {
navigator.clipboard.writeText(`${window.location.origin.toString()}/${id}`);
}
return (
<div className="flex flex-col w-full gap-1">
{data.map(note => {
@ -42,6 +41,16 @@ function NotesList({ data, onDeleteNote }: NotesLitsProps) {
>
<Edit className="h-5 w-5 " />
</Button>
<Button
variant="transparent"
size={'icon'}
aria-label="Copy Note"
title="Copy Note"
className="rounded-full hover:bg-black"
onClick={() => copyNoteLink(note.gist_url_key)}
>
<Copy className="h-5 w-5 " />
</Button>
<Link
href={`/notes/${note.gist_url_key}`}
aria-label="Go to Note"