From f20b25f7c2f865b895c490b87c39407378d2a8c1 Mon Sep 17 00:00:00 2001 From: jehousoh Date: Thu, 14 Nov 2024 03:53:36 +0800 Subject: [PATCH] Fix add and edit question Fix username cookie update Add turn server --- frontend/src/app/(user)/user/me/page.tsx | 4 +- .../admin/components/AddQuestionDialog.tsx | 2 +- .../admin/components/EditQuestionDialog.tsx | 379 +++++++++--------- .../app/collaboration/components/video.tsx | 20 + 4 files changed, 218 insertions(+), 187 deletions(-) diff --git a/frontend/src/app/(user)/user/me/page.tsx b/frontend/src/app/(user)/user/me/page.tsx index 2b60142bbc..223612e191 100644 --- a/frontend/src/app/(user)/user/me/page.tsx +++ b/frontend/src/app/(user)/user/me/page.tsx @@ -18,14 +18,13 @@ import { getUserId, updateUser, getFileUrl, - ToastComponent, resetPasswordFromProfile, + setUsername, } from "@/api/user"; import { useEffect, useRef, useState } from "react"; import { User } from "@/types/user"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; -import Swal from "sweetalert2"; import { CgProfile } from "react-icons/cg"; import MoonLoader from "react-spinners/MoonLoader"; import { IoCloseCircle } from "react-icons/io5"; @@ -122,6 +121,7 @@ const ProfilePage = () => { ) => { await updateUser(data); setUser(data); + if (data.username) setUsername(data.username); }; const onResetPasswordSubmit = async ( diff --git a/frontend/src/app/admin/components/AddQuestionDialog.tsx b/frontend/src/app/admin/components/AddQuestionDialog.tsx index d364a6c501..d6b9671c2b 100644 --- a/frontend/src/app/admin/components/AddQuestionDialog.tsx +++ b/frontend/src/app/admin/components/AddQuestionDialog.tsx @@ -215,7 +215,7 @@ const AddQuestionDialog = ({ {fields.map((example, index) => (
(true); const form = useForm({ resolver: zodResolver(formSchema), @@ -105,6 +106,7 @@ const EditQuestionDialog = ({ }; setQuestionData(questionData); reset(questionData); + setIsLoading(false); }); }, [questionId, reset]); @@ -152,196 +154,205 @@ const EditQuestionDialog = ({
Edit Question
-
- - ( - - - Question Title - - - - - - - )} - /> + {isLoading ? ( + + ) : ( + + + ( + + + Question Title + + + + + + + )} + /> - ( - - Difficulty - - - - - - )} - /> + ( + + Difficulty + + + + + + )} + /> - ( - - Topics - - - - - - )} - /> + ( + + Topics + + + + + + )} + /> - ( - - Description - -