From c4bb14345ccbb89ab9b840f9e7b24899055a6ac9 Mon Sep 17 00:00:00 2001 From: Shruti Bokil Date: Tue, 19 May 2026 15:41:07 +0530 Subject: [PATCH 1/2] feat: Add Copy profile url link button --- src/components/CopyLinkButton.tsx | 23 +++++++++++++++++++++++ src/components/DashboardHeader.tsx | 2 ++ tsconfig.json | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/components/CopyLinkButton.tsx diff --git a/src/components/CopyLinkButton.tsx b/src/components/CopyLinkButton.tsx new file mode 100644 index 00000000..3e6412c6 --- /dev/null +++ b/src/components/CopyLinkButton.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { useState } from "react"; + +export default function CopyLinkButton() { + const [ isCopied, setCopied ] = useState(false); + + const dataCopy = async () => { + await navigator.clipboard.writeText(window.location.href); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + return ( + + ); +} \ No newline at end of file diff --git a/src/components/DashboardHeader.tsx b/src/components/DashboardHeader.tsx index effb33e5..556e1a80 100644 --- a/src/components/DashboardHeader.tsx +++ b/src/components/DashboardHeader.tsx @@ -7,6 +7,7 @@ import SignOutButton from "@/components/SignOutButton"; import ThemeToggle from "@/components/ThemeToggle"; import UserAvatar from "@/components/UserAvatar"; import KeyboardShortcuts from "@/components/KeyboardShortcuts"; +import CopyLinkButton from "./CopyLinkButton"; export default function DashboardHeader() { const { data: session } = useSession(); @@ -62,6 +63,7 @@ export default function DashboardHeader() { )} + diff --git a/tsconfig.json b/tsconfig.json index d0fd9315..9b708bb6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ { From a3a80cbba3109282180caa78153b636e8ba951b6 Mon Sep 17 00:00:00 2001 From: Shruti Bokil Date: Tue, 19 May 2026 17:46:26 +0530 Subject: [PATCH 2/2] fix: copy correct public profile URL using session.githubLogin --- package.json | 3 ++- src/components/CopyLinkButton.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index af35b0c1..608b63c1 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "eslint-config-next": "14.2.3", "postcss": "^8.4.38", "tailwindcss": "^3.4.1", - "typescript": "^5" + "typescript": "^5", + "@playwright/test": "^1.49.1" } } diff --git a/src/components/CopyLinkButton.tsx b/src/components/CopyLinkButton.tsx index 3e6412c6..7941b36b 100644 --- a/src/components/CopyLinkButton.tsx +++ b/src/components/CopyLinkButton.tsx @@ -1,12 +1,14 @@ "use client"; import { useState } from "react"; +import { useSession } from "next-auth/react" export default function CopyLinkButton() { + const { data: session } = useSession(); const [ isCopied, setCopied ] = useState(false); - + const dataCopy = async () => { - await navigator.clipboard.writeText(window.location.href); + await navigator.clipboard.writeText(`${window.location.origin}/u/${session?.githubLogin}`); setCopied(true); setTimeout(() => setCopied(false), 2000); };