Skip to content

Commit

Permalink
Deeplink error handling (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
KeinAsylum authored Oct 22, 2024
1 parent 32e8cc4 commit 58693f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/common/init/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const initSentry = async (dsn: string) => {
levels: ['error', 'warn'],
}),
],
tracesSampleRate: 0.01,
tracesSampleRate: 0.1,
});
};

Expand Down
17 changes: 14 additions & 3 deletions src/components/ViewContainer/PaymentFormView/CardForm/CardForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Spacer, VStack, Text, Flex, Button, LightMode } from '@chakra-ui/react';
import { Spacer, VStack, Text, Flex, Button, LightMode, useToast } from '@chakra-ui/react';
import { useContext } from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';

Expand All @@ -10,7 +10,7 @@ import {
PaymentModelContext,
ViewModelContext,
} from 'checkout/contexts';
import { isNil } from 'checkout/utils';
import { extractError, isNil } from 'checkout/utils';

import { CardHolderFormControl } from './CardHolderFormControl';
import { CardNumberFormControl } from './CardNumberFormControl';
Expand Down Expand Up @@ -47,6 +47,8 @@ export function CardForm() {

const deepLink = initContext?.deepLink;

const toast = useToast();

return (
<form onSubmit={handleSubmit(onSubmit)}>
<VStack align="stretch" spacing={5}>
Expand Down Expand Up @@ -79,7 +81,16 @@ export function CardForm() {
<Button
onClick={() => {
// window.open(deepLink, '_self');
window.location.replace(deepLink);
try {
window.location.replace(deepLink);
} catch (ex) {
toast({
description: extractError(ex),
status: 'error',
duration: 20000,
isClosable: true,
});
}
}}
>
Go to deep link
Expand Down

0 comments on commit 58693f8

Please sign in to comment.