9bcb923cc0
* feat: add risk warning modal WIP * feat: add risk notice modal and fix broken mobile dialog styles * fix: format * fix: lint * fix: format * fix: dialog scrollbar * fix: style issues * fix: styles * fix: spacing * fix: more style fixes * fix: more spacing * fix: format * fix: move logic into risk dialog from global app * fix: brance yourselves, more style updates * feat: add test for risk dialog
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { useMarketList } from '@vegaprotocol/market-list';
|
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
|
import { useRouter } from 'next/router';
|
|
import { useEffect } from 'react';
|
|
import { useGlobalStore } from '../stores';
|
|
|
|
export function Index() {
|
|
const { replace } = useRouter();
|
|
// The default market selected in the platform behind the overlay
|
|
// should be the oldest market that is currently trading in continuous mode(i.e. not in auction).
|
|
const { data, error, loading } = useMarketList();
|
|
const { vegaRiskNoticeDialog, setLandingDialog } = useGlobalStore(
|
|
(store) => store
|
|
);
|
|
|
|
useEffect(() => {
|
|
setLandingDialog(true);
|
|
|
|
if (data) {
|
|
const marketId = data[0]?.id;
|
|
|
|
if (marketId) {
|
|
setLandingDialog(true);
|
|
replace(`/markets/${marketId}`);
|
|
}
|
|
// Fallback to the markets list page
|
|
else {
|
|
replace('/markets');
|
|
}
|
|
}
|
|
}, [data, replace, vegaRiskNoticeDialog, setLandingDialog]);
|
|
|
|
return (
|
|
<AsyncRenderer data={data} loading={loading} error={error}>
|
|
{/* Render a loading and error state but we will redirect if markets are found */}
|
|
{null}
|
|
</AsyncRenderer>
|
|
);
|
|
}
|
|
|
|
Index.getInitialProps = () => ({
|
|
page: 'home',
|
|
});
|
|
|
|
export default Index;
|