// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React, { useState, useRef } from 'react'; import { PrimaryButton } from 'amazon-chime-sdk-component-library-react'; import { StyledDiv } from './Styled'; interface SIPProps { sipURI: string; } const SIPURI: React.FC = ({ sipURI }: SIPProps) => { const sipUriEl: any = useRef(null); const [isCopied, setIsCopied] = useState(false); const copySIPURI = (): void => { const selection = window.getSelection(); if (selection) { try { const range = document.createRange(); range.selectNodeContents(sipUriEl.current); selection.removeAllRanges(); selection.addRange(range); document.execCommand('copy'); selection.removeAllRanges(); setIsCopied(true); setTimeout(() => setIsCopied(false), 2000); } catch (error) { console.error('Could not copy content'); } } else { console.error('Could not get window selection to copy content'); } }; return (
SIP URI

{sipURI}

{document.queryCommandSupported('copy') && ( )}
); }; export default SIPURI;