diff --git a/internal/ui/src/components/id.tsx b/internal/ui/src/components/id.tsx index 379c44635..e0322b22e 100644 --- a/internal/ui/src/components/id.tsx +++ b/internal/ui/src/components/id.tsx @@ -5,72 +5,72 @@ import { cn } from "../lib/utils"; import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip"; type IdProps = { - /** - * Value displayed on the component. - */ - value: string; - /** - * Number to truncate the value to. If the value is longer than the truncate number, it will be truncated and an ellipse will be added to the end. - */ - truncate?: number; - /** - * Any additional classes to apply to the component. - */ - className?: string; + /** + * Value displayed on the component. + */ + value: string; + /** + * Number to truncate the value to. If the value is longer than the truncate number, it will be truncated and an ellipse will be added to the end. + */ + truncate?: number; + /** + * Any additional classes to apply to the component. + */ + className?: string; }; export const Id: React.FC = ({ className, value, truncate, ...props }) => { - const [isCopied, setIsCopied] = React.useState(false); - const copyTextToClipboard = async (value: string) => { - try { - await navigator.clipboard.writeText(value ?? ""); - setIsCopied(true); - } catch (error) { - console.error("Failed to copy: ", error); - } - }; + const [isCopied, setIsCopied] = React.useState(false); + const copyTextToClipboard = async (value: string) => { + try { + await navigator.clipboard.writeText(value); + setIsCopied(true); + } catch (error) { + console.error("Failed to copy: ", error); + } + }; - React.useEffect(() => { - if (!isCopied) { - return; - } - const timer = setTimeout(() => { - setIsCopied(false); - }, 2000); - return () => clearTimeout(timer); - }, [isCopied]); + React.useEffect(() => { + if (!isCopied) { + return; + } + const timer = setTimeout(() => { + setIsCopied(false); + }, 2000); + return () => clearTimeout(timer); + }, [isCopied]); - const ellipse = "••••"; - const truncateValue = truncate ? value?.slice(0, truncate) + ellipse : value; + const ellipse = "••••"; + const truncateValue = truncate ? value?.slice(0, truncate) + ellipse : value; - return ( - - ); + return ( + + ); }; Id.displayName = "Id";