-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from Learn-and-Give/develop
Release/v1.7.0
- Loading branch information
Showing
44 changed files
with
642 additions
and
326 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import axios from "axios"; | ||
import { apiV2 } from "../myApi"; | ||
import { LoginProps } from "./types"; | ||
|
||
const postLogin = async (loginBody: LoginProps) => { | ||
return await axios.post( | ||
"https://prod.kkamjidot.com/v2/user/login", | ||
loginBody | ||
); | ||
return await apiV2.post("/user/login", loginBody); | ||
}; | ||
|
||
export { postLogin }; |
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,10 @@ | ||
import { getToken } from "../getToken"; | ||
import { api } from "../myApi"; | ||
|
||
const fetchMyPoint = async () => { | ||
api.defaults.headers.common["jwt"] = getToken(); | ||
const { data } = await api.get("/my/point"); | ||
return data; | ||
}; | ||
|
||
export { fetchMyPoint }; |
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,30 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { AxiosError } from "axios"; | ||
import { fetchQuizSolve } from "."; | ||
import { QuizSolve, QuizSolveSelect } from "../../types/Quiz"; | ||
import { QuizProps } from "./types"; | ||
|
||
function useQuizSolveQuery({ quizId }: QuizProps) { | ||
return useQuery<QuizSolve, AxiosError, QuizSolveSelect>( | ||
["quizSolve", quizId], | ||
() => fetchQuizSolve({ quizId }), | ||
{ | ||
enabled: !!quizId, | ||
select: (data) => { | ||
return { | ||
...data, | ||
quiz: { | ||
...data.quiz, | ||
rubric: JSON.parse(data.quiz.rubric).map( | ||
(value: { score: string; content: string }) => { | ||
return { ...value, score: Number(value.score) }; | ||
} | ||
), | ||
}, | ||
}; | ||
}, | ||
} | ||
); | ||
} | ||
|
||
export { useQuizSolveQuery }; |
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,25 @@ | ||
import { getToken } from "../getToken"; | ||
import { api, apiV2 } from "../myApi"; | ||
import { QuizAnswerProps, QuizGradeProps, QuizProps } from "./types"; | ||
|
||
const updateQuizIsSolved = async ({ quizId, answer }: QuizAnswerProps) => { | ||
api.defaults.headers.common["jwt"] = getToken(); | ||
|
||
return await api.post(`/quizzes/${quizId}/solve`, { answer }); | ||
}; | ||
|
||
const updateQuizGrade = async ({ quizId, scoreBody }: QuizGradeProps) => { | ||
apiV2.defaults.headers.common["jwt"] = getToken(); | ||
|
||
return await apiV2.post(`/quizzes/${quizId}/grade`, scoreBody); | ||
}; | ||
|
||
const fetchQuizSolve = async ({ quizId }: QuizProps) => { | ||
apiV2.defaults.headers.common["jwt"] = getToken(); | ||
|
||
const { data } = await apiV2.get(`/quizzes/${quizId}/solve`); | ||
|
||
return data; | ||
}; | ||
|
||
export { updateQuizIsSolved, updateQuizGrade, fetchQuizSolve }; |
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,16 @@ | ||
interface QuizProps { | ||
quizId: string; | ||
} | ||
|
||
interface QuizAnswerProps extends QuizProps { | ||
answer: string; | ||
} | ||
|
||
interface QuizGradeProps extends QuizProps { | ||
scoreBody: { | ||
score: number; | ||
solveRubric: string; | ||
}; | ||
} | ||
|
||
export type { QuizProps, QuizAnswerProps, QuizGradeProps }; |
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
Oops, something went wrong.