diff --git a/apis/quiz.ts b/apis/quiz.ts new file mode 100644 index 00000000..a884950c --- /dev/null +++ b/apis/quiz.ts @@ -0,0 +1,19 @@ +export const getCompletedQuizzes = async (wallet: string) => { + try { + const result = await fetch( + `https://api.mngo.cloud/data/v4/user-data/all-completed-quizzes?wallet-pk=${wallet}`, + ) + const solved = await result.json() + return solved?.length + ? (solved as { + wallet_pk: string + mango_account: string + quiz_id: number + points: number + }[]) + : [] + } catch (e) { + console.log(e) + return [] + } +} diff --git a/components/modals/UserSetupModal.tsx b/components/modals/UserSetupModal.tsx index 3ee02b9e..c74c91d0 100644 --- a/components/modals/UserSetupModal.tsx +++ b/components/modals/UserSetupModal.tsx @@ -276,7 +276,7 @@ const UserSetupModal = ({ src="/logos/logo-mark.svg" alt="next" /> -
{quiz.name} Quiz
+{intro.description}
+ {intro?.docs ? ( + + {intro.docs.linkText} + + ) : null} + ++ {!connected + ? 'Connect wallet to earn rewards points' + : solved?.find((x) => x.quiz_id === quiz.id) + ? 'Rewards Points Claimed' + : mangoAccountAddress + ? `Score ${quiz.questions.length}/${quiz.questions.length} to earn rewards points` + : 'Create a Mango Account to earn rewards points'} +
+You scored
+ + {((result.correctAnswers / questions.length) * 100).toFixed()}% + + {result.correctAnswers !== questions.length ? ( ++ Try again to earn rewards points. +
+Correct Answers
++ {result.correctAnswers} +
+Wrong Answers
++ {result.wrongAnswers.length} +
++ {answer.question} +
++ {answer.explanation} +
+Wrong Answers
+0
++ Earn rewards points for becoming a quiz master. +
+