All files / lib/pages/Ranking/UserIdCell index.tsx

0% Statements 0/9
0% Branches 0/4
0% Functions 0/4
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
import { CopyOutlined } from '@ant-design/icons';
import { message } from 'antd';
import React from 'react';
 
export function UserIdCell({ children }: React.PropsWithChildren) {
  const [isShow, setIsShow] = React.useState(false);
 
  const handleClick = async () => {
    if (typeof children !== 'string') return;
 
    await navigator.clipboard.writeText(children);
 
    message.success(`[${children}] 클립보드에 복사되었습니다.`);
  };
 
  return (
    // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events, jsx-a11y/click-events-have-key-events
    <div
      onMouseOver={() => setIsShow(true)}
      onMouseOut={() => setIsShow(false)}
      onClick={handleClick}
      style={{ cursor: 'pointer' }}
    >
      {children}
      <CopyOutlined style={{ visibility: isShow ? 'visible' : 'hidden', marginLeft: '8px' }} />
    </div>
  );
}