2023-09-12 18:52:03 +00:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
2023-03-31 13:23:44 +00:00
|
|
|
import { useCallback } from 'react';
|
2023-09-20 20:28:34 +00:00
|
|
|
import { Links } from '../../lib/links';
|
2023-03-31 13:23:44 +00:00
|
|
|
|
|
|
|
export const useMarketClickHandler = (replace = false) => {
|
|
|
|
const navigate = useNavigate();
|
2023-07-24 08:37:18 +00:00
|
|
|
|
2023-09-12 18:52:03 +00:00
|
|
|
return (selectedId: string, metaKey?: boolean) => {
|
2023-09-20 20:28:34 +00:00
|
|
|
const link = Links.MARKET(selectedId);
|
2023-09-12 18:52:03 +00:00
|
|
|
if (metaKey) {
|
|
|
|
window.open(`/#${link}`, '_blank');
|
|
|
|
} else {
|
|
|
|
navigate(link, { replace });
|
|
|
|
}
|
|
|
|
};
|
2023-03-31 13:23:44 +00:00
|
|
|
};
|
2023-04-18 12:55:11 +00:00
|
|
|
|
2023-06-21 11:23:07 +00:00
|
|
|
export const useMarketLiquidityClickHandler = () => {
|
|
|
|
return useCallback((selectedId: string, metaKey?: boolean) => {
|
|
|
|
window.open(`/#/liquidity/${selectedId}`, metaKey ? '_blank' : '_self');
|
|
|
|
}, []);
|
2023-04-18 12:55:11 +00:00
|
|
|
};
|