From 01e226893598a07ded45f04aedaa7c8da9b0af36 Mon Sep 17 00:00:00 2001 From: pheobeayo Date: Tue, 17 Dec 2024 20:43:45 +0100 Subject: [PATCH] feat(component): implemented a copy link button for copying invited codes --- apps/dashboard/src/pages/group.tsx | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/apps/dashboard/src/pages/group.tsx b/apps/dashboard/src/pages/group.tsx index da96f0d8..28b0913b 100644 --- a/apps/dashboard/src/pages/group.tsx +++ b/apps/dashboard/src/pages/group.tsx @@ -51,6 +51,18 @@ export default function GroupPage(): JSX.Element { const navigate = useNavigate() const addMembersModal = useDisclosure() const toast = useToast() + const [inviteCode, setInviteCode] = useState("") + const [inviteLink, setInviteLink] = useState("") + const { hasCopied: hasCopiedInviteCode, onCopy: onCopyInviteCode } = + useClipboard(inviteCode) + const { hasCopied: hasCopiedInviteLink, onCopy: onCopyInviteLink } = + useClipboard(inviteLink || "") + + const generateInviteCodeAndLink = () => { + const code = Math.random().toString(36).substring(2, 10).toUpperCase() + setInviteCode(code) + setInviteLink(`https://example.com/invite?code=${code}`) + } const { groupId, groupType } = useParams() const [_group, setGroup] = useState() // const { hasCopied, setValue: setApiKey, onCopy } = useClipboard("") @@ -450,6 +462,90 @@ ${memberIds.join("\n")} ( + + {/* Invite Code Section */} + Invite Code + + + + + e.preventDefault()} + icon={ + + } + /> + + + + + {/* Invite Link Section */} + + Invite Link + + + + + + e.preventDefault()} + icon={ + + } + /> + + + + + {/* Generate Button */} + +