diff --git a/frontend/src/pages/profile.tsx b/frontend/src/pages/profile.tsx index 8a1bc2c2..7ec99f65 100644 --- a/frontend/src/pages/profile.tsx +++ b/frontend/src/pages/profile.tsx @@ -43,6 +43,7 @@ export default function Profile() { const [followCount, setFollowCount] = useState(0); const [bookmarkedPosts, setBookmarkedPosts] = useState([]); const [solvedQuizzes, setSolvedQuizzes] = useState([]); + const [createdQuizzes, setCreatedQuizzes] = useState([]); const [isLoading, setIsLoading] = useState(true); useEffect(() => { @@ -117,7 +118,7 @@ export default function Profile() { } ) .then((response) => { - console.log(response.data); + console.log("solved", response.data); const solved = response.data.map(convertQuizResponseToQuiz); setSolvedQuizzes(solved); }) @@ -126,6 +127,26 @@ export default function Profile() { }); }, [token]); + useEffect(() => { + axios + .get( + `${BASE_URL}/quiz/created/${username}/`, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) + .then((response) => { + console.log(response.data); + const createdquiz = response.data.map(convertQuizResponseToQuiz); + setCreatedQuizzes(createdquiz); + }) + .catch((error) => { + console.log(error); + }); + }, [token]); + const toggleFollow = () => { axios .post( @@ -186,7 +207,7 @@ export default function Profile() {

{profile.username}

@{profile.level}

-

+

{profile.bio || "Hey, new learner here!"}

@@ -272,7 +293,24 @@ export default function Profile() { } > -

+
+ {createdQuizzes.map((quiz) => ( + }> + + + ))} +