import React from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import { CopyAllOutlined } from '@mui/icons-material';

import styles from './CopyCell.module.scss';

function CopyCell(props) {
  const router = useRouter();
  const handleClick = (e) => {
    e.preventDefault();
    const link = props.buildCopyLinkFunction(props.row, true);
    router.push(link);
  };

  return (
    <div className={styles.Wrapper}>
      <CopyAllOutlined fontSize="small" onClick={handleClick} htmlColor="primary.main" />
    </div>
  );
}

CopyCell.propTypes = {
  row: PropTypes.objectOf(PropTypes.shape({})).isRequired,
  buildCopyLinkFunction: PropTypes.func.isRequired,
};

export default CopyCell;
