Add copy invitation link to clipboard in guests-list.tsx
This commit is contained in:
@@ -17,8 +17,6 @@ import { getServerFileUrl } from "@/lib/utils";
|
|||||||
const InvitationPage = () => {
|
const InvitationPage = () => {
|
||||||
const { slug } = useParams<{ slug: string }>();
|
const { slug } = useParams<{ slug: string }>();
|
||||||
const { event, fetchEventBySlug, isLoadingEvent, eventError } = useEvents();
|
const { event, fetchEventBySlug, isLoadingEvent, eventError } = useEvents();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
|
||||||
const [notFound, setNotFound] = useState(false);
|
|
||||||
const [showRSVP, setShowRSVP] = useState(false);
|
const [showRSVP, setShowRSVP] = useState(false);
|
||||||
const { themes, isLoadingThemes } = useEventThemes();
|
const { themes, isLoadingThemes } = useEventThemes();
|
||||||
const guestId = "current-guest-id-placeholder";
|
const guestId = "current-guest-id-placeholder";
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import {
|
|||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from "@/components/ui/alert-dialog";
|
} from "@/components/ui/alert-dialog";
|
||||||
import { useAuth } from "@/context/auth-context";
|
import { useAuth } from "@/context/auth-context";
|
||||||
|
import { generateInviteLink } from "@/lib/utils";
|
||||||
|
|
||||||
// Helper to generate a random invitation code
|
// Helper to generate a random invitation code
|
||||||
const generateInvitationCode = (fullName: string): string => {
|
const generateInvitationCode = (fullName: string): string => {
|
||||||
@@ -272,9 +273,9 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Copy invitation code to clipboard
|
// Copy invitation code to clipboard
|
||||||
const copyToClipboard = (text: string) => {
|
const copyToClipboard = (text: string, message: string) => {
|
||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
toast("Invitation code copied to clipboard");
|
toast(message);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Export guest list to CSV
|
// Export guest list to CSV
|
||||||
@@ -553,7 +554,12 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-6 w-6"
|
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" />
|
<Copy className="h-3 w-3" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -575,10 +581,28 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
Edit
|
Edit
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => copyToClipboard(guest.invitation_code)}
|
onClick={() =>
|
||||||
|
copyToClipboard(
|
||||||
|
guest.invitation_code,
|
||||||
|
"Invitation code copied to clipboard",
|
||||||
|
)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Copy Invitation Code
|
Copy Invitation Code
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() =>
|
||||||
|
copyToClipboard(
|
||||||
|
generateInviteLink(
|
||||||
|
event.slug,
|
||||||
|
guest.invitation_code,
|
||||||
|
),
|
||||||
|
"Invitation link copied to clipboard",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Copy Invitation Link
|
||||||
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem>Resend Invitation</DropdownMenuItem>
|
<DropdownMenuItem>Resend Invitation</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
|
|||||||
Reference in New Issue
Block a user