From 271f9569fa45c341d89e598822a40a431853df0e Mon Sep 17 00:00:00 2001 From: Praful Date: Sun, 12 May 2024 13:15:20 +0530 Subject: [PATCH] Added Invite Functionality --- public/assets/icons/invite.svg | 1 + src/components/shared/LeftSidebar.tsx | 44 ++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 public/assets/icons/invite.svg diff --git a/public/assets/icons/invite.svg b/public/assets/icons/invite.svg new file mode 100644 index 0000000..63b7138 --- /dev/null +++ b/public/assets/icons/invite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/shared/LeftSidebar.tsx b/src/components/shared/LeftSidebar.tsx index dc01f3b..b404460 100644 --- a/src/components/shared/LeftSidebar.tsx +++ b/src/components/shared/LeftSidebar.tsx @@ -15,6 +15,28 @@ const LeftSidebar = () => { if (isSuccess) navigate(0); }, [isSuccess]); + const handleInviteClick = () => { + const currentURL = "https://opengram.vercel.app/sign-in"; + navigator.clipboard.writeText(`Hey! I am inviting you to join this amazing Social Media Application: ${currentURL}`) + .then(() => { + const popup = document.createElement('div'); + popup.textContent = "Invitation copied to clipboard!"; + popup.classList.add( + "fixed", "top-1/2", "left-1/2", "transform", "-translate-x-1/2", "-translate-y-1/2", + "bg-white", "text-black", "px-4", "py-2", "rounded", "z-50" + ); + document.body.appendChild(popup); + + setTimeout(() => { + document.body.removeChild(popup); + }, 3000); + }) + .catch((error: Error) => { + console.error("Failed to copy URL: ", error); + alert("Failed to copy URL!"); + }); + }; + return (