mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-09-23 16:32:54 +02:00

Also: - Move generic Toggle to componentfolder root - Remove dead styles - Refactor some componets
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import React, { useEffect, useState, lazy, Suspense } from 'react';
|
|
import { ReactRelayContext } from 'react-relay';
|
|
import { connectToStores } from 'fluxible-addons-react';
|
|
import Loading from '../Loading';
|
|
import withBreakpoint from '../../util/withBreakpoint';
|
|
import { getMapLayerOptions } from '../../util/mapLayerUtils';
|
|
|
|
const ItineraryPage = lazy(() => import('./ItineraryPage'));
|
|
|
|
const ItineraryPageWithBreakpoint = withBreakpoint(props => (
|
|
<ReactRelayContext.Consumer>
|
|
{({ environment }) => (
|
|
<ItineraryPage {...props} relayEnvironment={environment} />
|
|
)}
|
|
</ReactRelayContext.Consumer>
|
|
));
|
|
|
|
const ItineraryPageWithStores = connectToStores(
|
|
ItineraryPageWithBreakpoint,
|
|
['MapLayerStore'],
|
|
({ getStore }) => ({
|
|
mapLayers: getStore('MapLayerStore').getMapLayers({
|
|
notThese: ['stop', 'citybike', 'vehicles'],
|
|
}),
|
|
mapLayerOptions: getMapLayerOptions({
|
|
lockedMapLayers: ['vehicles', 'citybike', 'stop'],
|
|
selectedMapLayers: ['vehicles'],
|
|
}),
|
|
}),
|
|
);
|
|
|
|
export default function ItineraryPageContainer(props) {
|
|
const [isClient, setClient] = useState(false);
|
|
|
|
useEffect(() => {
|
|
// To prevent SSR from rendering something https://reactjs.org/docs/react-dom.html#hydrate
|
|
setClient(true);
|
|
});
|
|
if (!isClient) {
|
|
return <Loading />;
|
|
}
|
|
return (
|
|
<Suspense fallback={<Loading />}>
|
|
<ItineraryPageWithStores {...props} />
|
|
</Suspense>
|
|
);
|
|
}
|