Skip to content

Commit 9a02162

Browse files
authored
Merge pull request #245 from Markkos89/staging
[STAGING] Feat: wallet connected validation to take quiz added
2 parents a4bd206 + 1fc0289 commit 9a02162

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/components/mdx/QuizStatusChecker.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
33
/* eslint-disable @typescript-eslint/no-unsafe-return */
44
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
5-
import { Badge, Text } from "@chakra-ui/react";
5+
import { Badge, Center, Text } from "@chakra-ui/react";
66
import Quiz from "./Quiz";
77
import { useMemo, useState } from "react";
88
import { useSession } from "next-auth/react";
99
import { api } from "@/utils/api";
10+
import { useAccount } from "wagmi";
11+
import { ConnectButton } from "@rainbow-me/rainbowkit";
1012

1113
type QuizStatusCheckerTye = {
1214
quiz: string;
@@ -16,6 +18,7 @@ const QuizStatusChecker = ({ quiz }: QuizStatusCheckerTye) => {
1618
const [fetchNow, setFetchNow] = useState<boolean>(true);
1719
const [quizCompleted, setQuizCompleted] = useState<boolean>(false);
1820
const { data: sessionData } = useSession();
21+
const { address, isDisconnected } = useAccount();
1922

2023
// Requests
2124

@@ -49,9 +52,25 @@ const QuizStatusChecker = ({ quiz }: QuizStatusCheckerTye) => {
4952
}
5053
}, [allLessons, completedQuizzesAllData, fetchNow, quiz]);
5154

52-
if (completedQuizzesAllData === undefined) return null;
53-
54-
return quizCompleted ? (
55+
return isDisconnected || !address ? (
56+
<>
57+
<Center>
58+
<Text
59+
fontWeight="bold"
60+
fontSize="1.875rem"
61+
letterSpacing={-0.025}
62+
color="yellow.300"
63+
as="u"
64+
>
65+
Connect your wallet and Sign in to start the quiz
66+
</Text>{" "}
67+
</Center>
68+
<br />
69+
<Center>
70+
<ConnectButton />
71+
</Center>
72+
</>
73+
) : quizCompleted ? (
5574
<Badge
5675
display="flex"
5776
margin="auto"

0 commit comments

Comments
 (0)