chore: add metaKey detection - improve marketNameCell template

This commit is contained in:
maciek
2023-03-29 12:05:19 +02:00
parent 48ed158756
commit 95b55ea6aa
@@ -1,7 +1,6 @@
import type { MouseEvent } from 'react';
import { useCallback } from 'react';
import get from 'lodash/get';
import { useNavigate } from 'react-router-dom';
import { Link } from 'react-router-dom';
const MARKET_PATH = 'markets';
@@ -19,7 +18,6 @@ export const MarketNameCell = ({
idPath,
onMarketClick,
}: MarketNameCellProps) => {
const navigate = useNavigate();
const id = data ? get(data, idPath ?? 'id', 'all') : '';
const marketLink = `/${MARKET_PATH}/${id}`;
const handleOnClick = useCallback(
@@ -30,13 +28,8 @@ export const MarketNameCell = ({
onMarketClick(id, ev.metaKey);
return;
}
if (ev.metaKey) {
window.open(`/#${marketLink}`, '_blank');
} else {
navigate(marketLink);
}
},
[marketLink, navigate, id, onMarketClick]
[id, onMarketClick]
);
if (!data) return null;
return (