11import { redirect } from "next/navigation" ;
22import Link from "next/link" ;
33import { createClient as createServerClient } from "../../lib/supabase/server" ;
4- import { Cinzel } from 'next/font/google' ; // Import Cinzel font
4+ import { Cinzel } from "next/font/google" ; // Import Cinzel font
5+ import checkUserCompletedQuizzes from "@/lib/checkUserCompletedQuizzes" ;
56
67//font for words
78const cinzel = Cinzel ( {
@@ -26,34 +27,42 @@ export default async function DashboardPage() {
2627 redirect ( "/login" ) ;
2728 }
2829
29- const celestialButtonClasses = "btn border-2 border-cyan-400 text-cyan-400 bg-transparent hover:bg-cyan-900/50 hover:border-cyan-200 hover:text-cyan-200 shadow-lg shadow-cyan-500/50 transition duration-300 ease-in-out w-full" ;
30- const celestialButtonNoFullWidth = "btn border-2 border-cyan-400 text-cyan-400 bg-transparent hover:bg-cyan-900/50 hover:border-cyan-200 hover:text-cyan-200 shadow-lg shadow-cyan-500/50 transition duration-300 ease-in-out" ;
30+ // Check which quizzes has the user completed
31+ const completedQuizzes = await checkUserCompletedQuizzes ( ) ;
3132
33+ const isHelloWorldComplete = completedQuizzes . has ( "hello-world" ) ;
34+ const isVariablesComplete = completedQuizzes . has ( "variables" ) ;
35+
36+ const celestialButtonClasses =
37+ "btn border-2 border-cyan-400 text-cyan-400 bg-transparent hover:bg-cyan-900/50 hover:border-cyan-200 hover:text-cyan-200 shadow-lg shadow-cyan-500/50 transition duration-300 ease-in-out w-full" ;
38+ const celestialButtonNoFullWidth =
39+ "btn border-2 border-cyan-400 text-cyan-400 bg-transparent hover:bg-cyan-900/50 hover:border-cyan-200 hover:text-cyan-200 shadow-lg shadow-cyan-500/50 transition duration-300 ease-in-out" ;
40+ const greyButtonClass =
41+ "btn border-2 border-gray-400 text-gray-400 bg-transparent hover:bg-gray-900/50 hover:border-gray-200 hover:text-gray-200 shadow-lg shadow-gray-500/50 transition duration-300 ease-in-out" ;
42+ const greenButtonClass =
43+ "btn border-2 border-emerald-400 text-emerald-400 bg-transparent hover:bg-emerald-900/50 hover:border-emerald-200 hover:text-emerald-200 shadow-lg shadow-emerald-500/50 transition duration-300 ease-in-out" ;
3244
3345 return (
3446 < main
3547 className = { `relative min-h-dvh p-8 text-white ${ cinzel . className } ` }
3648 style = { {
3749 backgroundImage : "url('/dashboard.png')" ,
38- backgroundSize : ' cover' ,
39- backgroundPosition : ' center' ,
50+ backgroundSize : " cover" ,
51+ backgroundPosition : " center" ,
4052 } }
4153 >
42- < div className = "flex justify-between items-start w-full" >
43-
44- < div className = "flex flex-col gap-4 p-0 w-fit" >
45- < h1 className = "text-white text-5xl font-bold tracking-wider mb-4" >
46- Dashboard
47- </ h1 >
48- < div className = "flex flex-col gap-4 w-32" >
54+ < div className = "flex justify-between items-start w-full" >
55+ < div className = "flex flex-col gap-4 p-0 w-fit" >
56+ < h1 className = "text-white text-5xl font-bold tracking-wider mb-4" > Dashboard</ h1 >
57+ < div className = "flex flex-col gap-4 w-32" >
4958 < Link href = "/" className = { celestialButtonClasses } aria-label = "Go home" >
5059 < span > Home</ span >
5160 </ Link >
5261 </ div >
5362 </ div >
5463
5564 { /* profile & logout */ }
56- < div className = "flex items-center gap-4 p-0 w-fit" >
65+ < div className = "flex items-center gap-4 p-0 w-fit" >
5766 < Link href = "/profile" className = { celestialButtonNoFullWidth } aria-label = "Go to profile" >
5867 < span > Profile</ span >
5968 </ Link >
@@ -66,11 +75,14 @@ export default async function DashboardPage() {
6675 </ div >
6776
6877 { /* tutorials */ }
69- < div className = "absolute bottom-16 left-1/2 -translate-x-1/2" >
70- < Link href = "tutorial-hello-world" className = { celestialButtonNoFullWidth } >
71- Hello World
72- </ Link >
73- </ div >
78+ < div className = "absolute bottom-16 left-1/2 -translate-x-1/2" >
79+ < Link
80+ href = "tutorial-hello-world"
81+ className = { isHelloWorldComplete ? greenButtonClass : greyButtonClass }
82+ >
83+ Hello World
84+ </ Link >
85+ </ div >
7486 </ main >
7587 ) ;
76- }
88+ }
0 commit comments