Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions src/components/transactions/FlowCommons/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { DuplicateIcon, XIcon } from '@heroicons/react/outline';
import { Trans } from '@lingui/macro';
import { Box, Button, Link, SvgIcon, Typography } from '@mui/material';
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 (
<>
Expand All @@ -15,7 +31,7 @@ export const TxErrorView = ({ txError }: { txError: TxErrorType }) => {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
mb: '92px',
mb: '60px',
}}
>
<Box
Expand All @@ -39,26 +55,30 @@ export const TxErrorView = ({ txError }: { txError: TxErrorType }) => {
<Trans>Transaction failed</Trans>
</Typography>

<Typography>
<Trans>
You can report incident to our{' '}
<Link href="https://discord.com/invite/aave">Discord</Link> or
<Link href="https://github.com/aave/interface">Github</Link>.
</Trans>
<Typography sx={{ mt: 1 }}>
<Trans>Need help? Our support team can assist.</Trans>
</Typography>

<Button
variant="outlined"
onClick={() => navigator.clipboard.writeText(txError.rawError.message.toString())}
size="small"
sx={{ mt: 6 }}
>
<Trans>Copy error text</Trans>
<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>
<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' }}>
Expand Down
17 changes: 14 additions & 3 deletions src/layouts/SupportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ import { SUPPORT } from 'src/utils/events';
import { useShallow } from 'zustand/shallow';

export const SupportModal = () => {
const [feedbackDialogOpen, setFeedbackOpen, isTrackingEnabled] = useRootStore(
const [
feedbackDialogOpen,
setFeedbackOpen,
isTrackingEnabled,
supportPrefillMessage,
setSupportPrefillMessage,
] = useRootStore(
useShallow((state) => [
state.feedbackDialogOpen,
state.setFeedbackOpen,
state.isTrackingEnabled,
state.supportPrefillMessage,
state.setSupportPrefillMessage,
])
);
const [account, trackEvent] = useRootStore(
Expand All @@ -51,8 +59,9 @@ export const SupportModal = () => {
setSuccess(false);
setError(false);
setEmailError('');
setValue(supportPrefillMessage || '');
}
}, [feedbackDialogOpen]);
}, [feedbackDialogOpen, supportPrefillMessage]);

const handleEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const emailValue = e.target.value;
Expand Down Expand Up @@ -114,6 +123,7 @@ export const SupportModal = () => {
setEmail('');
setIsShareWalletApproved(false);
setCountry(null);
setSupportPrefillMessage(undefined);
}
};

Expand All @@ -127,6 +137,7 @@ export const SupportModal = () => {
setSuccess(false);
setError(false);
setCountry(null);
setSupportPrefillMessage(undefined);
};

return (
Expand Down Expand Up @@ -296,7 +307,7 @@ export const SupportModal = () => {
/>

{account && !hasOptedIn && (
<Box sx={{ mt: 2, p: 2, bgcolor: 'grey.50', borderRadius: 1.5 }}>
<Box sx={{ mt: 2, p: 2, bgcolor: 'background.surface', borderRadius: 1.5 }}>
<FormControlLabel
control={
<Checkbox
Expand Down
2 changes: 1 addition & 1 deletion src/locales/el/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ msgstr "Please connect your wallet to swap collateral."
msgid "Asset cannot be migrated due to supply cap restriction in {marketName} v3 market."
msgstr "Asset cannot be migrated due to supply cap restriction in {marketName} v3 market."

#: src/components/transactions/FlowCommons/Error.tsx
msgid "Need help? Our support team can assist."
msgstr "Need help? Our support team can assist."

#: src/modules/sGho/SavingsGhoCard.tsx
msgid "Initiate Withdraw"
msgstr "Initiate Withdraw"
Expand Down Expand Up @@ -1002,10 +1006,6 @@ msgstr "Claiming all protocol rewards only. Merit rewards excluded - select \"cl
msgid "Collateralization"
msgstr "Collateralization"

#: src/components/transactions/FlowCommons/Error.tsx
msgid "You can report incident to our <0>Discord</0> or<1>Github</1>."
msgstr "You can report incident to our <0>Discord</0> or<1>Github</1>."

#: src/components/MarketSwitcher.tsx
msgid "Main Ethereum market with the largest selection of assets and yield options"
msgstr "Main Ethereum market with the largest selection of assets and yield options"
Expand Down Expand Up @@ -1065,6 +1065,10 @@ msgstr "Reactivate cooldown period to unstake {0} {stakedToken}"
msgid "Migrate to v3"
msgstr "Migrate to v3"

#: src/components/transactions/FlowCommons/Error.tsx
msgid "Get support"
msgstr "Get support"

#: src/components/transactions/Bridge/BridgeModalContent.tsx
msgid "The source chain time to finality is the main factor that determines the time to destination. <0>Learn more</0>"
msgstr "The source chain time to finality is the main factor that determines the time to destination. <0>Learn more</0>"
Expand Down
2 changes: 1 addition & 1 deletion src/locales/es/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/fr/messages.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/store/layoutSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type LayoutSlice = {
mobileDrawerOpen: boolean;
feedbackDialogOpen: boolean;
setFeedbackOpen: (eventName: boolean) => void;
supportPrefillMessage?: string;
setSupportPrefillMessage: (message?: string) => void;
};

export const createLayoutSlice: StateCreator<
Expand All @@ -18,11 +20,15 @@ export const createLayoutSlice: StateCreator<
return {
mobileDrawerOpen: false,
feedbackDialogOpen: false,
supportPrefillMessage: undefined,
setMobileDrawerOpen: (value: boolean) => {
set({ mobileDrawerOpen: value });
},
setFeedbackOpen: (value: boolean) => {
set({ feedbackDialogOpen: value });
},
setSupportPrefillMessage: (message?: string) => {
set({ supportPrefillMessage: message });
},
};
};
Loading