Skip to content

Commit 38a706f

Browse files
authored
Merge pull request #145 from defikids/staging
Add changes to releaseReady
2 parents b281c07 + 7f5e5c0 commit 38a706f

File tree

93 files changed

+5232
-1455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+5232
-1455
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ SENDGRID_API_KEY="<Sengrid-API-Key>"
1919
SENDGRID_TRANSPORTER_EMAIL_ADDRESS="<Sendgrid-Email-Address>"
2020

2121
# https://www.mongodb.com/basics/mongodb-connection-string
22-
MONGODB_URI="<MondoDB-URI>"
22+
MONGODB_URI="<MondoDB-URI>"
23+
24+
# https://docs.alchemy.com/reference/ethereum-api-quickstart
25+
NEXT_PUBLIC_ALCHEMY_GOERLI="API-Key"

app/confirm-email/[token]/page.tsx

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ import {
1010
Image,
1111
Button,
1212
} from "@chakra-ui/react";
13-
import { usePathname, useRouter } from "next/navigation";
13+
import { usePathname } from "next/navigation";
1414
import jwt from "jsonwebtoken";
1515
import { useEffect, useMemo, useState } from "react";
1616
import { useSignMessage, useAccount } from "wagmi";
1717
import { ethers } from "ethers";
1818
import { CustomConnectButton } from "@/components/ConnectButton";
1919
import { User } from "@/data-schema/types";
20-
import { useAuthStore } from "@/store/auth/authStore";
21-
import { shallow } from "zustand/shallow";
2220
import { editUser, getUserByWalletAddress } from "@/services/mongo/routes/user";
21+
import { useAuthStore } from "@/store/auth/authStore";
22+
import shallow from "zustand/shallow";
2323

2424
export default function ConfirmEmail() {
2525
const [isConfirmed, setIsConfirmed] = useState(false);
2626
const [emailVerified, setEmailVerified] = useState(false);
2727
const [disabled, setDisabled] = useState(false);
28-
const [countdown, setCountdown] = useState(5);
2928
const [decodedWalletAddress, setDecodedWalletAddress] = useState<string>("");
3029
const [user, setUser] = useState<User | null>(null);
3130
const [initialUseCheck, setInitialUseCheck] = useState(false);
3231

33-
const router = useRouter();
3432
const pathname = usePathname();
3533

3634
const token = useMemo(() => {
@@ -44,46 +42,14 @@ export default function ConfirmEmail() {
4442

4543
const message = "Confirm Email Address";
4644

47-
const { setUserDetails } = useAuthStore(
48-
(state) => ({
49-
setUserDetails: state.setUserDetails,
50-
}),
51-
shallow
52-
);
53-
54-
const redirectUser = async () => {
55-
let count = 5;
56-
57-
// Countdown function
58-
const countdown = async () => {
59-
if (count === 0) {
60-
const updatedUserDetails = await getUserByWalletAddress(
61-
user?.wallet || ""
62-
);
63-
setUserDetails(updatedUserDetails);
64-
router.push("/");
65-
} else {
66-
setTimeout(() => {
67-
count--;
68-
setCountdown(count);
69-
countdown();
70-
}, 1000);
71-
}
72-
};
73-
74-
countdown(); // Start the countdown
75-
};
76-
7745
const updateUserEmailVerified = async (emailVerified: boolean) => {
7846
const body = {
7947
...user,
8048
emailVerified,
8149
};
8250

8351
await editUser(user?.accountId!, body);
84-
8552
setEmailVerified(true);
86-
redirectUser();
8753
};
8854

8955
/*
@@ -168,7 +134,7 @@ export default function ConfirmEmail() {
168134
setUser(user);
169135

170136
if (user.data?.emailVerified) {
171-
redirectUser();
137+
setEmailVerified(true);
172138
}
173139
}
174140
}
@@ -227,7 +193,7 @@ export default function ConfirmEmail() {
227193
Your email address was successfully authenticated.
228194
</Text>
229195
<Text my={5} color="gray" fontSize="lg">
230-
{`Your will be redirected to the DefiKids app in ${countdown} seconds.`}
196+
You may close this window.
231197
</Text>
232198
</Flex>
233199
</Box>

app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default function RootLayout({
1717
children: React.ReactNode;
1818
}) {
1919
return (
20-
<html lang="en">
21-
<body>
20+
<html lang="en" suppressHydrationWarning={true}>
21+
<body suppressHydrationWarning={true}>
2222
<Providers>
2323
<Auth />
2424
<ConditionalNavBars />
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { Box } from "@chakra-ui/react";
22
import MemberDashboardClientLayout from "@/components/dashboards/memberDashboard/MemberDashboardClientLayout";
3+
import { getUserByWalletAddress } from "@/services/mongo/routes/user";
4+
import { User } from "@/data-schema/types";
35

46
const getProps = async (context: any) => {
57
const { memberAddress } = context.params || {};
68

9+
const user = await getUserByWalletAddress(memberAddress);
10+
711
return {
8-
memberAddress,
12+
user,
913
};
1014
};
1115

12-
export default async function MemberLockerPage(context: any) {
13-
const { memberAddress } = (await getProps(context)) as {
14-
memberAddress: string;
16+
export default async function MemberDashboard(context: any) {
17+
const { user } = (await getProps(context)) as {
18+
user: User;
1519
};
1620

1721
return (
1822
<Box height="100vh">
19-
<MemberDashboardClientLayout memberAddress={memberAddress} />
23+
<MemberDashboardClientLayout user={user} />
2024
</Box>
2125
);
2226
}

app/member-invite/[token]/page.tsx

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import {
3939
import { TestnetNetworks } from "@/data-schema/enums";
4040
import mongoose from "mongoose";
4141
import { convertTimestampToSeconds } from "@/utils/dateTime";
42+
import { ethers } from "ethers";
43+
import { getSignerAddress } from "@/blockchain/utils";
4244

4345
interface DecodedToken {
4446
accountId: mongoose.Schema.Types.ObjectId;
@@ -68,10 +70,8 @@ const MemberInvite = () => {
6870
const [inviteNonExistent, setInviteNonExistent] = useState(false);
6971
const [username, setUsername] = useState("");
7072

71-
const { setUserDetails, userDetails, reset } = useAuthStore(
73+
const { reset } = useAuthStore(
7274
(state) => ({
73-
setUserDetails: state.setUserDetails,
74-
userDetails: state.userDetails,
7575
reset: state.reset,
7676
}),
7777
shallow
@@ -81,7 +81,7 @@ const MemberInvite = () => {
8181
if (!decodedToken) return;
8282

8383
const { email, accountId } = decodedToken;
84-
console.log("createMember - userDetails", userDetails);
84+
8585
try {
8686
let userPayload = {
8787
accountId,
@@ -118,27 +118,6 @@ const MemberInvite = () => {
118118
}
119119
};
120120

121-
const redirectUser = async () => {
122-
let count = 5;
123-
124-
// Countdown function
125-
const countdown = async () => {
126-
if (count === 0) {
127-
const updatedUserDetails = await getUserByWalletAddress(address);
128-
setUserDetails(updatedUserDetails.data);
129-
router.push("/");
130-
} else {
131-
setTimeout(() => {
132-
count--;
133-
setCountdown(count);
134-
countdown();
135-
}, 1000);
136-
}
137-
};
138-
139-
countdown(); // Start the countdown
140-
};
141-
142121
const handleToken = async () => {
143122
if (!username) {
144123
toast({
@@ -192,11 +171,6 @@ const MemberInvite = () => {
192171
);
193172
};
194173

195-
// Reset store on page load
196-
useEffect(() => {
197-
reset();
198-
}, []);
199-
200174
// Check if wallet has already been registered and if invite has already been accepted
201175
useEffect(() => {
202176
if (!decodedData) return;
@@ -227,7 +201,6 @@ const MemberInvite = () => {
227201
await deleteInvitation(invitation._id);
228202

229203
setInviteAccepted(true);
230-
redirectUser();
231204
} catch (error) {
232205
console.error("Error fetching data:", error);
233206
}
@@ -246,8 +219,24 @@ const MemberInvite = () => {
246219
Your account was successfully created.
247220
</Text>
248221
<Text my={5} color="gray" fontSize="lg">
249-
{`Your will be redirected to the DefiKids app in ${countdown} seconds.`}
222+
You may close this window.
250223
</Text>
224+
<Button
225+
mt="3rem"
226+
colorScheme="gray"
227+
size="lg"
228+
style={{
229+
cursor: "pointer",
230+
borderRadius: "10px",
231+
padding: "15px",
232+
}}
233+
onClick={() => {
234+
reset();
235+
router.push(`/member-dashboard/${address}`);
236+
}}
237+
>
238+
<Text fontSize={"lg"}>Go to Dashboard</Text>
239+
</Button>
251240
</Flex>
252241
</Box>
253242
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Box } from "@chakra-ui/react";
2+
import ParentDashboardClientLayout from "@/components/dashboards/parentDashboard/ParentDashboardClientLayout";
3+
4+
export default async function ParentDashboard(context: any) {
5+
return (
6+
<Box height="100vh">
7+
<ParentDashboardClientLayout />
8+
</Box>
9+
);
10+
}

0 commit comments

Comments
 (0)