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