|
1 | 1 | import PropTypes from 'prop-types'; |
2 | | -import React, { useContext, lazy, Suspense } from 'react'; |
| 2 | +import React, { useContext } from 'react'; |
3 | 3 | import { graphql, QueryRenderer, ReactRelayContext } from 'react-relay'; |
4 | 4 | import { intlShape } from 'react-intl'; |
| 5 | +import Modal from '@hsl-fi/modal'; |
5 | 6 | import Loading from './Loading'; |
6 | 7 | import DisruptionListContainer from './DisruptionListContainer'; |
7 | 8 |
|
8 | | -const Modal = lazy(() => import('@hsl-fi/modal')); |
9 | | - |
10 | 9 | export default function DisruptionInfo(props, context) { |
11 | 10 | const { setOpen } = props; |
12 | 11 | const { intl } = context; |
13 | 12 | const { environment } = useContext(ReactRelayContext); |
14 | 13 |
|
15 | 14 | return ( |
16 | | - <Suspense fallback=""> |
17 | | - <Modal |
18 | | - appElement="#app" |
19 | | - closeButtonLabel={intl.formatMessage({ id: 'close' })} |
20 | | - contentLabel={intl.formatMessage({ |
21 | | - id: 'disruption-info', |
22 | | - defaultMessage: 'Disruption info', |
23 | | - })} |
24 | | - isOpen |
25 | | - onCrossClick={() => setOpen(false)} |
26 | | - onClose={() => setOpen(false)} |
27 | | - shouldCloseOnEsc |
28 | | - shouldCloseOnOverlayClick |
29 | | - > |
30 | | - <div className="momentum-scroll" style={{ maxHeight: '80vh' }}> |
31 | | - <QueryRenderer |
32 | | - cacheConfig={{ force: true, poll: 30 * 1000 }} |
33 | | - query={graphql` |
34 | | - query DisruptionInfoQuery($feedIds: [String!]) { |
35 | | - viewer { |
36 | | - ...DisruptionListContainer_viewer |
37 | | - @arguments(feedIds: $feedIds) |
38 | | - } |
| 15 | + <Modal |
| 16 | + appElement="#app" |
| 17 | + closeButtonLabel={intl.formatMessage({ id: 'close' })} |
| 18 | + contentLabel={intl.formatMessage({ |
| 19 | + id: 'disruption-info', |
| 20 | + defaultMessage: 'Disruption info', |
| 21 | + })} |
| 22 | + isOpen |
| 23 | + onCrossClick={() => setOpen(false)} |
| 24 | + onClose={() => setOpen(false)} |
| 25 | + shouldCloseOnEsc |
| 26 | + shouldCloseOnOverlayClick |
| 27 | + > |
| 28 | + <div className="momentum-scroll" style={{ maxHeight: '80vh' }}> |
| 29 | + <QueryRenderer |
| 30 | + cacheConfig={{ force: true, poll: 30 * 1000 }} |
| 31 | + query={graphql` |
| 32 | + query DisruptionInfoQuery($feedIds: [String!]) { |
| 33 | + viewer { |
| 34 | + ...DisruptionListContainer_viewer @arguments(feedIds: $feedIds) |
39 | 35 | } |
40 | | - `} |
41 | | - variables={{ feedIds: context.config.feedIds }} |
42 | | - environment={environment} |
43 | | - render={({ props: innerProps }) => |
44 | | - innerProps ? ( |
45 | | - <> |
46 | | - <h2> |
47 | | - {intl.formatMessage({ |
48 | | - id: 'disruption-info', |
49 | | - defaultMessage: 'Disruption info', |
50 | | - })} |
51 | | - </h2> |
52 | | - <DisruptionListContainer |
53 | | - onClickLink={() => setOpen(false)} |
54 | | - {...innerProps} |
55 | | - /> |
56 | | - </> |
57 | | - ) : ( |
58 | | - <Loading /> |
59 | | - ) |
60 | 36 | } |
61 | | - /> |
62 | | - </div> |
63 | | - </Modal> |
64 | | - </Suspense> |
| 37 | + `} |
| 38 | + variables={{ feedIds: context.config.feedIds }} |
| 39 | + environment={environment} |
| 40 | + render={({ props: innerProps }) => |
| 41 | + innerProps ? ( |
| 42 | + <> |
| 43 | + <h2> |
| 44 | + {intl.formatMessage({ |
| 45 | + id: 'disruption-info', |
| 46 | + defaultMessage: 'Disruption info', |
| 47 | + })} |
| 48 | + </h2> |
| 49 | + <DisruptionListContainer |
| 50 | + onClickLink={() => setOpen(false)} |
| 51 | + {...innerProps} |
| 52 | + /> |
| 53 | + </> |
| 54 | + ) : ( |
| 55 | + <Loading /> |
| 56 | + ) |
| 57 | + } |
| 58 | + /> |
| 59 | + </div> |
| 60 | + </Modal> |
65 | 61 | ); |
66 | 62 | } |
67 | 63 |
|
|
0 commit comments