diff --git a/src/components/RoadCard/LongBadge.tsx b/src/components/RoadCard/LongBadge.tsx index 82d727e8b..2cfff1b3e 100644 --- a/src/components/RoadCard/LongBadge.tsx +++ b/src/components/RoadCard/LongBadge.tsx @@ -1,6 +1,9 @@ +import { useIsCopied } from '../../hooks/use-is-copied'; import type { BadgeProps } from './RoadCardPage'; export function LongBadge({ badgeUrl }: BadgeProps) { + const { isCopied, handleCopy } = useIsCopied(); + return (
- - Copy Link + Download +
); diff --git a/src/components/RoadCard/RoadCardPage.tsx b/src/components/RoadCard/RoadCardPage.tsx index 6020c2afb..86efc5110 100644 --- a/src/components/RoadCard/RoadCardPage.tsx +++ b/src/components/RoadCard/RoadCardPage.tsx @@ -5,6 +5,7 @@ import { WideBadge } from './WideBadge'; import { LongBadge } from './LongBadge'; import CopyIcon from '../../icons/copy.svg'; +import { useIsCopied } from '../../hooks/use-is-copied'; export type BadgeProps = { badgeUrl: string; @@ -12,7 +13,8 @@ export type BadgeProps = { export function RoadCardPage() { const [selectedBadge, setSelectedBadge] = useState<'long' | 'wide'>('long'); - const [isCopied, setIsCopied] = useState(false); + const { isCopied, handleCopy } = useIsCopied(); + const token = Cookies.get(TOKEN_COOKIE_NAME); if (!token) { return null; @@ -36,21 +38,6 @@ export function RoadCardPage() { `.trim(); - const handleCopyEmbed = () => { - navigator.clipboard.writeText(textareaContent); - setIsCopied(true); - }; - - useEffect(() => { - let timeout: ReturnType; - if (isCopied) { - timeout = setTimeout(() => { - setIsCopied(false); - }, 2000); - } - return () => clearTimeout(timeout); - }, [isCopied]); - return ( <>
@@ -98,11 +85,11 @@ export function RoadCardPage() { {selectedBadge === 'wide' && }
-
+
Embed