File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Frontend/src/Pages/Results Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -131,13 +131,15 @@ export const getFinishedQuizzes = async(req, res) => {
131131}
132132export const updateFinished = async ( req , res ) => {
133133 try {
134- const quizId = req . params . quizId ;
134+ const userId = req . params . id ;
135+ const quizId = req . body . quizId ;
135136
136137 const updatedQuiz = await Quiz . findOneAndUpdate (
137- { _id : quizId } , // filter by quiz ID and user ID
138- { $set : { completed : true } } , // update `completed` to true
139- { new : true } // return the updated document
140- ) ;
138+ { _id : quizId , user : userId } ,
139+ { $set : { completed : true } } ,
140+ { new : true }
141+ ) ;
142+ console . log ( updatedQuiz ) ;
141143 if ( ! updatedQuiz ) {
142144 return res . status ( 404 ) . json ( { error : 'Quiz not found or does not belong to the user' } ) ;
143145 }
Original file line number Diff line number Diff line change 11import "../../Styles/Pages/Results/Results.css"
22import { Podium , ResultCard } from "../../Components/Components"
33import { useState , useEffect } from "react"
4+ import { useNavigate } from "react-router-dom"
45
56const URI = import . meta. env . VITE_APP_URI
67const userId = JSON . parse ( localStorage . getItem ( 'id' ) ) ;
@@ -9,6 +10,10 @@ const Results = () => {
910 const win = "You beat the Quiz!"
1011 const lose = "Better luck next time..."
1112 const monstersSlain = localStorage . getItem ( 'results' ) || 0 ;
13+ const navigate = useNavigate ( )
14+ const goHome = ( ) => {
15+ navigate ( '/home' )
16+ }
1217 console . log ( "Monsters slain" , monstersSlain )
1318 const [ totalCoins , setTotalCoins ] = useState ( 0 )
1419
@@ -51,7 +56,7 @@ const Results = () => {
5156 </ div >
5257 </ div >
5358 </ div >
54- < button className = "from-results-to-home" > Continue</ button >
59+ < button className = "from-results-to-home" onClick = { goHome } > Continue</ button >
5560 </ div >
5661 </ >
5762 )
You can’t perform that action at this time.
0 commit comments