generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display question and swap question in collaboration rooms (#185)
- Loading branch information
1 parent
79d08bb
commit e09d0c5
Showing
30 changed files
with
619 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { AuthContext } from "@/contexts/AuthContext"; | ||
import { | ||
getMatchByRoomid as getMatchByRoomidApi, | ||
patchMatchQuestionByRoomid as patchMatchQuestionByRoomidApi, | ||
} from "@/pages/api/matchHandler"; | ||
import { User } from "firebase/auth"; | ||
import { useContext } from "react"; | ||
|
||
export const useMatch = () => { | ||
const { user: currentUser, authIsReady } = useContext(AuthContext); | ||
|
||
const getMatch = async (roomId: string) => { | ||
if (authIsReady && currentUser) { | ||
const match = await getMatchByRoomidApi(currentUser, roomId); | ||
return match; | ||
} | ||
}; | ||
|
||
const updateQuestionIdInMatch = async ( | ||
roomId: string, | ||
questionId: string | ||
) => { | ||
if (authIsReady && currentUser) { | ||
await patchMatchQuestionByRoomidApi(currentUser, roomId, questionId); | ||
} | ||
}; | ||
|
||
return { getMatch, updateQuestionIdInMatch }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.