1- import { db } from "../firebase" ;
2- import { doc , setDoc , updateDoc , getDoc } from "firebase/firestore" ;
31import Button from "../components/Button" ;
4- import { useState } from "react " ;
2+ import ChallengeTile from "../components/Challenges/ChallengeTile " ;
53
64export default function Challenges ( ) {
7- // use state to use data
8- const [ teamData , setTeamData ] = useState ( null ) ;
9-
10- // add a new document in the collection test function
11- async function writeTestDoc ( ) {
12- // create a collection with a document called team
13- try {
14- await setDoc ( doc ( db , "test" , "team" ) , {
15- name : "Mint Chip Mavericks" ,
16- sprintsCompleted : 3
17- } ) ;
18- console . log ( "New Team data added" )
19- } catch ( error ) {
20- console . error ( "The error found" , error ) ;
21- } ;
22- } ;
23-
24- // update data in an existing doc
25- async function addDataToDoc ( ) {
26- const teamDocRef = doc ( db , "test" , "team" )
27- await updateDoc ( teamDocRef , {
28- members : 3
29- } ) ;
30-
31- console . log ( "New field added" ) ;
32- } ;
33-
34- // read data in the doc to display
35- async function readTestDoc ( ) {
36- const teamDocRef = doc ( db , "test" , "team" ) ;
37- const teamDocSnap = await getDoc ( teamDocRef ) ;
38-
39- if ( teamDocSnap . exists ( ) ) {
40- console . log ( "document data" , teamDocSnap . data ( ) ) ;
41- setTeamData ( teamDocSnap . data ( ) ) ;
42- } else {
43- console . log ( "there is no data" )
44- } ;
45- } ;
46-
475 return (
48- < div className = "min-h-screen bg-emerald-100 flex flex-col gap-10 items-center justify-center" >
49- < h1 className = "text-4xl font-bold text-lime-500" > Challenges Page! 🎉</ h1 >
50-
51- { /* test write document button */ }
52- < Button onClick = { writeTestDoc } label = "create a collection/document" size = "lg" />
53-
54- { /* update test document button */ }
55- < Button onClick = { addDataToDoc } label = "add data field to a document" size = "lg" />
56-
57- { /* test read document button */ }
58- < Button onClick = { readTestDoc } label = "read a document and display data" size = "lg" />
59-
60- { /* tester sentence with the added firestore data */ }
61- { teamData && (
62- < p > { teamData . name } has { teamData . members } members and completed { teamData . sprintsCompleted } sprints!</ p >
63- ) }
64- </ div >
6+ < div className = "bg-white" >
7+ { /* title section */ }
8+ < div className = "flex flex-col mx-8 sm:mx-15 md:mx-10 lg:mx-20 xl:mx-40 2xl:mx-80" >
9+ < h1 className = "text-3xl font-playfair font-semibold text-eerie place-self-center lg:place-self-start mt-4" > Which task would you like to work on today?</ h1 >
10+ </ div >
11+
12+ { /* challenge tile grid */ }
13+ < div className = "grid grid-cols-1 md:grid-cols-6 gap-8 auto-rows-min my-10 mx-8 sm:mx-15 md:mx-10 lg:mx-20 xl:mx-40 2xl:mx-80" >
14+ { /* row 1 */ }
15+ < ChallengeTile
16+ size = "sm"
17+ span = "2"
18+ title = "Sleep 7-9 hours"
19+ subtitle = "Better sleep means a better you."
20+ tags = '#Sleep #Stress'
21+ />
22+ < ChallengeTile
23+ size = "sm"
24+ span = "2"
25+ title = "Read a Book"
26+ subtitle = "Destress by reading for at least 20 minutes a day."
27+ tags = '#Sleep #Stress'
28+ />
29+ < ChallengeTile
30+ size = "sm"
31+ span = "2"
32+ title = "Practice Saying No"
33+ subtitle = "Learn the different ways you can say no in & outside in the office."
34+ tags = '#Stress #SelfDoubt'
35+ />
36+
37+ { /* row 2 */ }
38+ < ChallengeTile
39+ size = "lg"
40+ span = "3"
41+ title = "Read Positive Affirmations"
42+ subtitle = "Recite empowering messages meant to help you fight self-doubt and anxiety."
43+ tags = '#Sleep #SelfDoubt #GenderBias #Postpartum'
44+ />
45+ < ChallengeTile
46+ size = "lg"
47+ span = "3"
48+ title = "Daily Journal Entry"
49+ subtitle = "Answer a different prompt each day or share what’s on your mind."
50+ tags = '#Stress #SelfDoubt #GenderBias #Postpartum'
51+ to = '/journal'
52+ />
53+ </ div >
54+ </ div >
6555 ) ;
6656} ;
0 commit comments