@rango-dev/widget-embedded 0.24.2-next.1 → 0.24.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.24.2-next.1",
3
+ "version": "0.24.2-next.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -4,7 +4,7 @@ import type { PropsWithChildren } from 'react';
4
4
 
5
5
  import { useManager } from '@rango-dev/queue-manager-react';
6
6
  import { BottomLogo, Divider, Header } from '@rango-dev/ui';
7
- import React, { useEffect, useRef } from 'react';
7
+ import React, { useEffect, useRef, useState } from 'react';
8
8
 
9
9
  import { WIDGET_UI_ID } from '../../constants';
10
10
  import { useIframe } from '../../hooks/useIframe';
@@ -20,6 +20,7 @@ import { isFeatureHidden } from '../../utils/settings';
20
20
  import { ActivateTabAlert } from '../common/ActivateTabAlert';
21
21
  import { ActivateTabModal } from '../common/ActivateTabModal';
22
22
  import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
23
+ import { RefreshModal } from '../RefreshModal';
23
24
 
24
25
  import { onScrollContentAttachStatusToContainer } from './Layout.helpers';
25
26
  import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
@@ -27,6 +28,8 @@ import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
27
28
  function Layout(props: PropsWithChildren<PropTypes>) {
28
29
  const { connectHeightObserver, disconnectHeightObserver } = useIframe();
29
30
  const { children, header, footer, height = 'fixed' } = props;
31
+ const { fetchStatus } = useAppStore();
32
+ const [openRefreshModal, setOpenRefreshModal] = useState(false);
30
33
  const connectedWallets = useWalletsStore.use.connectedWallets();
31
34
  const {
32
35
  config: { features, theme },
@@ -94,6 +97,10 @@ function Layout(props: PropsWithChildren<PropTypes>) {
94
97
  };
95
98
  }, []);
96
99
 
100
+ useEffect(() => {
101
+ setOpenRefreshModal(fetchStatus === 'failed');
102
+ }, [fetchStatus]);
103
+
97
104
  return (
98
105
  <Container
99
106
  height={height}
@@ -156,6 +163,10 @@ function Layout(props: PropsWithChildren<PropTypes>) {
156
163
  <BottomLogo />
157
164
  </div>
158
165
  </Footer>
166
+ <RefreshModal
167
+ open={openRefreshModal}
168
+ onClose={() => setOpenRefreshModal(false)}
169
+ />
159
170
  </Container>
160
171
  );
161
172
  }
@@ -0,0 +1,9 @@
1
+ import { Button, styled } from '@rango-dev/ui';
2
+
3
+ export const RefreshButton = styled(Button, {
4
+ '& span': {
5
+ display: 'flex',
6
+ justifyContent: 'center',
7
+ alignItems: 'center',
8
+ },
9
+ });
@@ -0,0 +1,39 @@
1
+ import type { PropTypes } from './RefreshModal.types';
2
+
3
+ import { i18n } from '@lingui/core';
4
+ import { Divider, MessageBox, RefreshIcon } from '@rango-dev/ui';
5
+ import React from 'react';
6
+
7
+ import { getContainer } from '../../utils/common';
8
+ import { WatermarkedModal } from '../common/WatermarkedModal';
9
+
10
+ import { RefreshButton } from './RefreshModal.styles';
11
+
12
+ export function RefreshModal(props: PropTypes) {
13
+ const { open, onClose } = props;
14
+
15
+ return (
16
+ <WatermarkedModal
17
+ open={open}
18
+ dismissible
19
+ onClose={onClose}
20
+ container={getContainer()}>
21
+ <MessageBox
22
+ title={i18n.t('Something wrong')}
23
+ type="error"
24
+ description={i18n.t('Something Wrong. Please refresh the app')}>
25
+ <Divider size={30} />
26
+ <RefreshButton
27
+ variant="outlined"
28
+ size="large"
29
+ type="primary"
30
+ fullWidth
31
+ onClick={() => location.reload()}>
32
+ <RefreshIcon size={20} color="primary" />
33
+ <Divider size={4} direction="horizontal" />
34
+ {i18n.t('Refresh')}
35
+ </RefreshButton>
36
+ </MessageBox>
37
+ </WatermarkedModal>
38
+ );
39
+ }
@@ -0,0 +1,4 @@
1
+ export type PropTypes = {
2
+ open: boolean;
3
+ onClose: () => void;
4
+ };
@@ -0,0 +1 @@
1
+ export { RefreshModal } from './RefreshModal';