import React, { useRef } from "react";
import { Table } from 'semantic-ui-react';

function ClickableTableRow(props) {
    const onClick = (e) => {
        if (e.ctrlKey || e.metaKey) {
            window.open(props.href, '_blank');
        } else {
            window.location.href = props.href;
        }
    }

    if (Object.keys(props).includes("allowClicks") && props.allowClicks == false) {
        return <Table.Row key={props.href}>{props.children}</Table.Row>
    }

    return (
        <Table.Row
            key={props.href}
            onClick={onClick}
            style={{cursor: 'pointer'}}
        >
            {props.children}
        </Table.Row>
    );
}

export default ClickableTableRow;
