Archived
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
66 lines
2.7 KiB
TypeScript
66 lines
2.7 KiB
TypeScript
"use client";
|
|
|
|
import { Share2, QrCode, CalendarPlus } from "lucide-react";
|
|
import QRCode from "qrcode";
|
|
import { API_BASE } from "@/lib/api";
|
|
|
|
type Props = { event: { id: string; title: string; description?: string | null } };
|
|
|
|
// The event's own address tagged with where the link was handed out, so visits from it
|
|
// show under that source in the funnel report (the page's canonical drops the tag for SEO).
|
|
function taggedEventUrl(source: string): string {
|
|
return `${window.location.origin}${window.location.pathname}?utm_source=${source}`;
|
|
}
|
|
|
|
export default function ClientActions({ event }: Props) {
|
|
return (
|
|
<div className="flex gap-2">
|
|
<button
|
|
onClick={async () => {
|
|
try {
|
|
await navigator.share({
|
|
title: event.title,
|
|
text: event.description ?? undefined,
|
|
url: taggedEventUrl("share"),
|
|
});
|
|
} catch (err) {
|
|
console.error("Error sharing:", err);
|
|
}
|
|
}}
|
|
className="flex items-center gap-2 px-4 py-2 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors text-sm font-medium"
|
|
>
|
|
<Share2 className="w-4 h-4" />
|
|
Share
|
|
</button>
|
|
<button
|
|
onClick={async () => {
|
|
try {
|
|
const url = taggedEventUrl("qr");
|
|
const qrDataUrl = await QRCode.toDataURL(url);
|
|
const link = document.createElement("a");
|
|
link.href = qrDataUrl;
|
|
link.download = `${event.title}-qr.png`;
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
} catch (err) {
|
|
console.error("Error generating QR code:", err);
|
|
}
|
|
}}
|
|
className="flex items-center gap-2 px-4 py-2 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors text-sm font-medium"
|
|
>
|
|
<QrCode className="w-4 h-4" />
|
|
Save QR
|
|
</button>
|
|
<a
|
|
href={`${API_BASE}/api/v2/events/${event.id}/calendar.ics`}
|
|
download
|
|
className="flex items-center gap-2 px-4 py-2 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors text-sm font-medium"
|
|
>
|
|
<CalendarPlus className="w-4 h-4" />
|
|
Add to calendar
|
|
</a>
|
|
</div>
|
|
);
|
|
}
|