-
Notifications
You must be signed in to change notification settings - Fork 480
Expand file tree
/
Copy pathError.tsx
More file actions
90 lines (82 loc) · 2.72 KB
/
Error.tsx
File metadata and controls
90 lines (82 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { DuplicateIcon, XIcon } from '@heroicons/react/outline';
import { Trans } from '@lingui/macro';
import { Box, Button, SvgIcon, Typography } from '@mui/material';
import { useModalContext } from 'src/hooks/useModal';
import { useRootStore } from 'src/store/root';
import { TxErrorType } from 'src/ui-config/errorMapping';
import { useShallow } from 'zustand/shallow';
export const TxErrorView = ({ txError }: { txError: TxErrorType }) => {
const { close } = useModalContext();
const [setFeedbackOpen, setSupportPrefillMessage] = useRootStore(
useShallow((state) => [state.setFeedbackOpen, state.setSupportPrefillMessage])
);
const handleGetSupport = () => {
const rawMessage = txError?.rawError?.message
? txError.rawError.message.toString()
: 'Unknown error';
const template = `I am coming from a transaction failure with this error:\n\n"${rawMessage}"`;
setSupportPrefillMessage(template);
setFeedbackOpen(true);
close();
};
return (
<>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
mb: '60px',
}}
>
<Box
sx={{
width: '48px',
height: '48px',
backgroundColor: 'error.200',
borderRadius: '50%',
mt: 14,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<SvgIcon sx={{ color: 'error.main', fontSize: '32px' }}>
<XIcon />
</SvgIcon>
</Box>
<Typography sx={{ mt: 2 }} variant="h2">
<Trans>Transaction failed</Trans>
</Typography>
<Typography sx={{ mt: 1 }}>
<Trans>Need help? Our support team can assist.</Trans>
</Typography>
<Box sx={{ display: 'flex', gap: 2, mt: 4 }}>
<Button variant="outlined" onClick={handleGetSupport} size="small">
<Trans>Get support</Trans>
</Button>
<Button
variant="outlined"
onClick={() =>
navigator.clipboard.writeText(
txError?.rawError?.message ? txError.rawError.message.toString() : 'Unknown error'
)
}
size="small"
>
<Trans>Copy error text</Trans>
<SvgIcon sx={{ ml: 0.5, fontSize: '12px' }}>
<DuplicateIcon />
</SvgIcon>
</Button>
</Box>
</Box>
<Box sx={{ display: 'flex', flexDirection: 'column', mt: 12 }}>
<Button onClick={close} variant="contained" size="large" sx={{ minHeight: '44px' }}>
<Trans>Close</Trans>
</Button>
</Box>
</>
);
};