copy link buttons for item detail and forum post
This commit is contained in:
@@ -222,6 +222,16 @@ const ForumPostDetail: React.FC = () => {
|
||||
setDeletionReason('');
|
||||
};
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
const shareUrl = `${window.location.origin}/forum/${post?.id}`;
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareUrl);
|
||||
} catch (err) {
|
||||
console.error("Copy to clipboard failed:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleString(undefined, {
|
||||
@@ -292,7 +302,17 @@ const ForumPostDetail: React.FC = () => {
|
||||
Pinned
|
||||
</span>
|
||||
)}
|
||||
<h1 className="h3 mb-2">{post.title}</h1>
|
||||
<div className="d-flex align-items-center justify-content-between mb-2">
|
||||
<h1 className="h3 mb-0">{post.title}</h1>
|
||||
<button
|
||||
className="btn btn-outline-secondary btn-sm"
|
||||
onClick={handleCopyLink}
|
||||
aria-label="Copy link to this post"
|
||||
>
|
||||
<i className="bi bi-link-45deg me-2"></i>
|
||||
Copy Link
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="d-flex gap-2 mb-2 flex-wrap">
|
||||
<div className="d-flex gap-2">
|
||||
|
||||
Reference in New Issue
Block a user