2023-09-12 18:52:03 +00:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
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-10-16 18:18:26 +00:00
|
|
|
export const useNavigateWithMeta = (replace = false) => {
|
2023-10-03 10:08:30 +00:00
|
|
|
const navigate = useNavigate();
|
|
|
|
|
2023-10-16 18:18:26 +00:00
|
|
|
return (link: string, metaKey?: boolean) => {
|
2023-10-03 10:08:30 +00:00
|
|
|
if (metaKey) {
|
|
|
|
window.open(`/#${link}`, '_blank');
|
|
|
|
} else {
|
|
|
|
navigate(link, { replace });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|