Skip to content

Commit

Permalink
- add error event
Browse files Browse the repository at this point in the history
- show error modal when back-end swap fails
- remove px value
  • Loading branch information
L03TJ3 committed Nov 8, 2023
1 parent 462d1c8 commit cfb84f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/good-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"cpx": "^1.5.0",
"css-loader": "^6.7.1",
"ctix": "^1.4.0",
"ethers": "5.7.2",
"lodash": "^4.17.21",
"raw-loader": "^4.0.2",
"react-device-detect": "^2.2.3",
Expand Down
9 changes: 5 additions & 4 deletions packages/good-design/src/apps/onramp/GdOnramperWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { useSignWalletModal } from "../../hooks/useSignWalletModal";

const ErrorModal = () => (
<View>
<Text>Error</Text>
<Text>Something went wrong.</Text>
</View>
);

interface IGdOnramperProps {
isTesting?: boolean;
onEvents: (action: string) => void;
onEvents: (action: string, error?: string) => void;
}

export const GdOnramperWidget = ({ isTesting = false, onEvents = noop }: IGdOnramperProps) => {
Expand Down Expand Up @@ -47,7 +47,6 @@ export const GdOnramperWidget = ({ isTesting = false, onEvents = noop }: IGdOnra
*/
const callback = useCallback((event: WebViewMessageEvent) => {
if ((event.nativeEvent.data as any).title === "success") {
console.log("User succesfully bought CELO/CUSD -- awaiting arrival in sc wallet...");
//start the stepper
setStep(1);
}
Expand Down Expand Up @@ -90,6 +89,7 @@ export const GdOnramperWidget = ({ isTesting = false, onEvents = noop }: IGdOnra
} catch (e: any) {
console.log("swap error:", e.message, e);
showModal();
onEvents("buygd_swap_failed", e.message);
setStep(-1);
}
};
Expand All @@ -99,7 +99,8 @@ export const GdOnramperWidget = ({ isTesting = false, onEvents = noop }: IGdOnra
if (cusdBalance?.gt(0) || celoBalance?.gt(0)) {
console.log("starting swap:", cusdBalance?.toString(), celoBalance?.toString());
triggerSwap().catch(e => {
console.log(e);
showModal();
onEvents("buygd_swap_failed", e.message);
});
}
}, [celoBalance, cusdBalance]);
Expand Down
2 changes: 0 additions & 2 deletions packages/good-design/src/apps/onramp/Onramper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const Onramper = ({
// SO fiddle: http://jsfiddle.net/wk1yv6q3/
useEffect(() => {
const checkFocus = (e: any) => {
console.log("checkFocus", { e, step });
if (document.activeElement === document.querySelector("iframe") && step === -1) {
onGdEvent("buy_start");
setStep(0);
Expand All @@ -112,7 +111,6 @@ export const Onramper = ({
}, [step]);

const devNextStep = useCallback(() => {
console.log("devNextStep", { step });
setStep(step + 1);
}, [step]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const theme = {
},
progressStyles: {
width: "80%",
height: "4px",
height: 1,
backgroundColor: "goodGrey.300",
borderRadius: 5,
overflow: "hidden"
Expand Down

0 comments on commit cfb84f0

Please sign in to comment.