Skip to content

Commit 5e61c4c

Browse files
feat: reshowedi editaddress when user cancels modal, add metamask extension and adjust styles
1 parent 7cbda78 commit 5e61c4c

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/components/sections/profile/modals/EditAddress/_partials/Form.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import EditAdressFooter from "./Footer";
1010
import { useDispatch } from "@/hooks/useTypedDispatch";
1111
import { setWeb3Address } from "@/store/feature/wallet.slice";
1212
import useWalletConnect from "@/hooks/useWalletConnect";
13+
import { modal } from "@/config/Web3Modal";
1314

1415
type Props = {
1516
connectionMethod: string;
@@ -21,6 +22,7 @@ type Props = {
2122
error: CustomError | undefined | null;
2223
clearError: () => void;
2324
show: boolean;
25+
openEditAddress: () => void;
2426
};
2527

2628
/**
@@ -52,7 +54,7 @@ interface FormValues {
5254
* @param {boolean} param0.show
5355
* @returns {*}
5456
*/
55-
export default function WalletAddressChangeForm({ connectionMethod, currentAddress, token, closeModal, onSave, loading, error, clearError, show }: Props) {
57+
export default function WalletAddressChangeForm({ connectionMethod, currentAddress, token, closeModal, onSave, loading, error, clearError, show, openEditAddress }: Props) {
5658
const { t } = useTranslation();
5759
const {
5860
watch,
@@ -101,6 +103,16 @@ export default function WalletAddressChangeForm({ connectionMethod, currentAddre
101103
}
102104
}, [walletConnectAddress]);
103105

106+
useEffect(() => {
107+
modal.subscribeEvents(({ data }) => {
108+
if (data.event === "MODAL_CLOSE" && !address) {
109+
openEditAddress();
110+
} else if (data.event === "CONNECT_ERROR") {
111+
modal.close();
112+
}
113+
});
114+
}, []);
115+
104116
return (
105117
<form className="flex flex-col" onSubmit={handleSubmit(save)}>
106118
{show && (

src/components/sections/profile/modals/EditAddress/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export default function EditProfile({ show, wallet, onClose }: EditProfileProps)
168168
connectionMethod={connectionMethod}
169169
closeModal={closeModal}
170170
clearError={() => setError(null)}
171+
openEditAddress={openEditAddress}
171172
/>
172173
</Modal>
173174
);

src/components/sections/profile/modals/MintCertificate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default function MintCertificate({ show, close }: { show: boolean; wallet
159159

160160
return (
161161
<Modal show={show} size="medium" onClose={onClose}>
162-
<div className="px-6 pt-6">
162+
<div className="px-6">
163163
<div className="pb-7">
164164
<p className="text-.5xl font-medium leading-snug">{achievement?.metadata?.name}</p>
165165
</div>
@@ -202,7 +202,7 @@ export default function MintCertificate({ show, close }: { show: boolean; wallet
202202
)}
203203
</div>
204204
</div>
205-
<div className="flex items-center justify-between my-8">
205+
<div className="flex items-center justify-between mt-8">
206206
<a className="text-sm font-medium cursor-pointer text-primary" onClick={onClose}>
207207
Close
208208
</a>

src/config/Web3Modal.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createWeb3Modal } from "@web3modal/wagmi/react";
1+
import { EIP6963Connector, createWeb3Modal } from "@web3modal/wagmi/react";
22
import { publicProvider } from "wagmi/providers/public";
33
import { configureChains, createConfig } from "wagmi";
4-
import { polygonMumbai } from "wagmi/chains";
4+
import { polygonMumbai, mainnet } from "wagmi/chains";
55
import { InjectedConnector } from "wagmi/connectors/injected";
66
import { WalletConnectConnector } from "wagmi/connectors/walletConnect";
77
import { walletConnectProvider } from "@web3modal/wagmi";
@@ -12,17 +12,21 @@ const metadata = {
1212
name: "Dacade",
1313
description: "Peer to peer learning platform",
1414
url: "https://dacade.org/",
15-
icons: ["https://asset.cloudinary.com/dl1vj7yr9/8b5ea898819e51aef029c7b7971f1168"],
15+
icons: ["https://dacade.org/fav-icons/apple-touch-icon.png"],
1616
};
1717

18-
const { chains, publicClient } = configureChains([polygonMumbai], [walletConnectProvider({ projectId }), publicProvider()]);
18+
const { chains, publicClient } = configureChains([polygonMumbai, mainnet], [walletConnectProvider({ projectId }), publicProvider()]);
1919
export const config = createConfig({
2020
autoConnect: true,
21-
connectors: [new WalletConnectConnector({ chains, options: { projectId, showQrModal: false, metadata } }), new InjectedConnector({ chains, options: { shimDisconnect: true } })],
21+
connectors: [
22+
new WalletConnectConnector({ chains, options: { projectId, showQrModal: false, metadata } }),
23+
new EIP6963Connector({ chains }),
24+
new InjectedConnector({ chains, options: { shimDisconnect: true } }),
25+
],
2226
publicClient,
2327
});
2428

25-
createWeb3Modal({
29+
export const modal = createWeb3Modal({
2630
wagmiConfig: config,
2731
projectId,
2832
chains,

0 commit comments

Comments
 (0)