From bda3b6667bf2b5a5eda33a958cec5d8c9b281a83 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Tue, 27 Feb 2024 16:43:09 +0530 Subject: [PATCH] changes as per feedback --- admin_frontend/.editorconfig | 12 +++++ frontend/.editorconfig | 12 +++++ frontend/.gitignore | 2 + frontend/src/components/ConnectedIcon.jsx | 12 ++--- frontend/src/components/Dashboard.jsx | 7 +-- frontend/src/components/Header.jsx | 45 ++++++++++-------- frontend/src/components/NotFound.jsx | 26 +++++------ frontend/src/components/ProtectedRoute.js | 2 +- .../src/components/TransactionSentToast.jsx | 46 +++++++++---------- frontend/src/context/AuthContext.js | 2 +- frontend/src/utils/constant.js | 4 ++ 11 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 admin_frontend/.editorconfig create mode 100644 frontend/.editorconfig diff --git a/admin_frontend/.editorconfig b/admin_frontend/.editorconfig new file mode 100644 index 0000000..64d3d6a --- /dev/null +++ b/admin_frontend/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/frontend/.editorconfig b/frontend/.editorconfig new file mode 100644 index 0000000..64d3d6a --- /dev/null +++ b/frontend/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore index f2ad830..2c69316 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -14,3 +14,5 @@ chrome-user-data .vscode *.swp *.swo + +.env.local diff --git a/frontend/src/components/ConnectedIcon.jsx b/frontend/src/components/ConnectedIcon.jsx index 4084f53..c83d494 100644 --- a/frontend/src/components/ConnectedIcon.jsx +++ b/frontend/src/components/ConnectedIcon.jsx @@ -1,13 +1,13 @@ import React, { Fragment } from "react"; const ColoredCircle = ({ color }) => { - const styles = { backgroundColor: color }; + const styles = { backgroundColor: color }; - return color ? ( - - - - ) : null; + return color ? ( + + + + ) : null; }; export default ColoredCircle; diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx index 4e6b07d..8831de0 100644 --- a/frontend/src/components/Dashboard.jsx +++ b/frontend/src/components/Dashboard.jsx @@ -30,6 +30,7 @@ import EtherspotLogo from "../assets/internal-36-etherspot@2x.png"; // constants import { networks } from "../utils/constant"; import EtherspotPaymasterAbi from "../abi/EtherspotPaymasterAbi.json"; +import { ENDPOINTS } from "../constants/constants"; const ITEM_HEIGHT = 48; const MenuProps = { @@ -137,7 +138,7 @@ const Dashboard = ({ logInType }) => { try { setIsLoading(true); const data = await ( - await fetch("http://localhost:5050/getSupportedNetworks", { + await fetch(`${process.env.REACT_APP_SERVER_URL}${ENDPOINTS['getSupportedNetworks']}`, { method: "POST", body: JSON.stringify({ WALLET_ADDRESS: address }), }) @@ -308,7 +309,7 @@ const Dashboard = ({ logInType }) => { setIsLoading(false); } catch (e) { console.error(e.message); - toast.error("Something went wrong on MetaMask"); + toast.error("Something went wrong while submitting. Please check your injected wallet"); setIsLoading(false); } }; @@ -364,7 +365,7 @@ const Dashboard = ({ logInType }) => { setIsLoading(false); } catch (err) { console.error(err); - toast.error("Something went wrong on MetaMask"); + toast.error("Something went wrong while submitting. Please check your injected wallet"); setIsLoading(false); } }; diff --git a/frontend/src/components/Header.jsx b/frontend/src/components/Header.jsx index 08b9559..2d8df95 100644 --- a/frontend/src/components/Header.jsx +++ b/frontend/src/components/Header.jsx @@ -6,35 +6,42 @@ import { styled } from "styled-components"; import { UserAuth } from "../context/AuthContext"; // assets -import EtherspotLogo from '../assets/internal-48-etherspot@2x.png'; +import EtherspotLogo from "../assets/internal-48-etherspot@2x.png"; const LogoText = styled.span` margin: '3px 0 4px 8px', font-size: '24px', text-align: 'center', color: '#cfcfcf' - ` + `; const Header = () => { - const { user, signIn } = UserAuth(); - const [signedIn, setSignedIn] = useState(false); + const { user, signIn } = UserAuth(); + const [signedIn, setSignedIn] = useState(false); - useEffect(() => { - if (user?.address) setSignedIn(true); - }, [user]) + useEffect(() => { + if (user?.address) setSignedIn(true); + }, [user]); - return ( -
-
- {'EtherspotLogo'} - Etherspot Arka -
- { signedIn ? {user?.address} : - } -
- ); + return ( +
+
+ {"EtherspotLogo"} + Etherspot Arka +
+ {signedIn ? ( + {user?.address} + ) : ( + + )} +
+ ); }; export default Header; diff --git a/frontend/src/components/NotFound.jsx b/frontend/src/components/NotFound.jsx index 647cad0..af9363d 100644 --- a/frontend/src/components/NotFound.jsx +++ b/frontend/src/components/NotFound.jsx @@ -4,21 +4,21 @@ import { useNavigate } from "react-router-dom"; import { UserAuth } from "../context/AuthContext"; const NotFound = () => { - const { user } = UserAuth(); - const navigate = useNavigate(); + const { user } = UserAuth(); + const navigate = useNavigate(); - useEffect(() => { - if(!user) { - toast.error('no such user exists'); - navigate('/'); - } - }, [user, navigate]); + useEffect(() => { + if (!user) { + toast.error("no such user exists"); + navigate("/"); + } + }, [user, navigate]); - return ( -
-

Page Not Found

-
- ); + return ( +
+

Page Not Found

+
+ ); }; export default NotFound; diff --git a/frontend/src/components/ProtectedRoute.js b/frontend/src/components/ProtectedRoute.js index 4eb97d7..8b7482d 100644 --- a/frontend/src/components/ProtectedRoute.js +++ b/frontend/src/components/ProtectedRoute.js @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import React, { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { UserAuth } from '../context/AuthContext'; diff --git a/frontend/src/components/TransactionSentToast.jsx b/frontend/src/components/TransactionSentToast.jsx index 6ed65ab..f8f6920 100644 --- a/frontend/src/components/TransactionSentToast.jsx +++ b/frontend/src/components/TransactionSentToast.jsx @@ -1,30 +1,30 @@ import toast from "react-hot-toast"; const TransactionSentToast = ({ t, blockExplorerLink, txHash }) => { - const openInExplorer = (txHash) => { - window.open(`${blockExplorerLink}${txHash}`, "_blank"); - }; + const openInExplorer = (txHash) => { + window.open(`${blockExplorerLink}${txHash}`, "_blank"); + }; - return ( -
- Transaction Sent - - -
- ); + return ( +
+ Transaction Sent + + +
+ ); }; export default TransactionSentToast; diff --git a/frontend/src/context/AuthContext.js b/frontend/src/context/AuthContext.js index 309e14c..4055dad 100644 --- a/frontend/src/context/AuthContext.js +++ b/frontend/src/context/AuthContext.js @@ -16,7 +16,7 @@ export const AuthContextProvider = ({ children }) => { params: [address, "latest"] }) return balance; - } catch(err) { + } catch (err) { console.error('Error on retrieving balance', err); return 0; } diff --git a/frontend/src/utils/constant.js b/frontend/src/utils/constant.js index c726b43..dbc7693 100644 --- a/frontend/src/utils/constant.js +++ b/frontend/src/utils/constant.js @@ -135,3 +135,7 @@ export const networks = { blockExplorerLink: 'https://snowtrace.io/tx/' } } + +export const ENDPOINTS = { + 'getSupportedNetworks': '/getSupportedNetworks' +}