import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { NextPage } from 'next' import { Quiz as QuizType, quizzes } from 'utils/quiz' import { useMemo } from 'react' import { CheckCircleIcon, ChevronRightIcon } from '@heroicons/react/20/solid' import { useRouter } from 'next/router' import Image from 'next/image' import { useCompletedQuizzes } from 'hooks/useQuiz' import Quiz from '@components/quiz/Quiz' import { useWallet } from '@solana/wallet-adapter-react' export async function getStaticProps({ locale }: { locale: string }) { return { props: { ...(await serverSideTranslations(locale, [ 'account', 'close-account', 'common', 'notifications', 'onboarding', 'profile', 'search', 'settings', ])), // Will be passed to the page component as props }, } } const shuffleQuiz = (quiz: QuizType) => { for (let i = quiz.questions.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)) ;[quiz.questions[i], quiz.questions[j]] = [ quiz.questions[j], quiz.questions[i], ] } return quiz } const Learn: NextPage = () => { // const { t } = useTranslation('common') const router = useRouter() const { quiz } = router.query const quizToShow = useMemo(() => { if (!quiz) return const index = quizzes.findIndex((q) => q.slug === quiz) const result = quizzes.find((q) => q.slug === quiz) return { quiz: result, index, } }, [quiz]) return !quizToShow?.quiz ? (

Learn 2 Earn

Earn rewards points for becoming a quiz master.

{[...quizzes].reverse().map((quiz, index) => ( ))}
) : (
) } const QuizCard = ({ quiz }: { quiz: QuizType }) => { const { publicKey } = useWallet() const { data: solved } = useCompletedQuizzes(publicKey?.toBase58()) const router = useRouter() const goToQuiz = (quiz: string) => { const query = { ...router.query, ['quiz']: quiz } router.push({ pathname: router.pathname, query }, undefined, { shallow: true, }) } return ( ) } export default Learn