Add copy invitation link to clipboard in guests-list.tsx
Some checks failed
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-frontend (push) Failing after 50s

This commit is contained in:
2025-03-16 10:59:08 +01:00
parent 86ae3ca234
commit 551a7ba9dc
2 changed files with 28 additions and 6 deletions

View File

@@ -17,8 +17,6 @@ import { getServerFileUrl } from "@/lib/utils";
const InvitationPage = () => {
const { slug } = useParams<{ slug: string }>();
const { event, fetchEventBySlug, isLoadingEvent, eventError } = useEvents();
const [isLoading, setIsLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
const [showRSVP, setShowRSVP] = useState(false);
const { themes, isLoadingThemes } = useEventThemes();
const guestId = "current-guest-id-placeholder";

View File

@@ -65,6 +65,7 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { useAuth } from "@/context/auth-context";
import { generateInviteLink } from "@/lib/utils";
// Helper to generate a random invitation code
const generateInvitationCode = (fullName: string): string => {
@@ -272,9 +273,9 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
};
// Copy invitation code to clipboard
const copyToClipboard = (text: string) => {
const copyToClipboard = (text: string, message: string) => {
navigator.clipboard.writeText(text);
toast("Invitation code copied to clipboard");
toast(message);
};
// Export guest list to CSV
@@ -553,7 +554,12 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
variant="ghost"
size="icon"
className="h-6 w-6"
onClick={() => copyToClipboard(guest.invitation_code)}
onClick={() =>
copyToClipboard(
guest.invitation_code,
"Invitation code copied to clipboard",
)
}
>
<Copy className="h-3 w-3" />
</Button>
@@ -575,10 +581,28 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
Edit
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => copyToClipboard(guest.invitation_code)}
onClick={() =>
copyToClipboard(
guest.invitation_code,
"Invitation code copied to clipboard",
)
}
>
Copy Invitation Code
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
copyToClipboard(
generateInviteLink(
event.slug,
guest.invitation_code,
),
"Invitation link copied to clipboard",
)
}
>
Copy Invitation Link
</DropdownMenuItem>
<DropdownMenuItem>Resend Invitation</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem