From 419c36c3179399dd2509b3a417b5060e1886c9ed Mon Sep 17 00:00:00 2001 From: Mai Ting Kai Date: Sun, 29 Sep 2024 17:48:52 +0800 Subject: [PATCH] Add fix --- frontend/src/api/leetcode-dashboard.tsx | 4 +--- .../(auth)/leetcode-dashboard/AddQuestionDialog.tsx | 7 ++++++- .../leetcode-dashboard/EditQuestionDialog.tsx | 7 ++++++- .../(auth)/leetcode-dashboard/LeetcodeDashboard.tsx | 2 +- .../leetcode-dashboard/LeetcodeDashboardTable.tsx | 13 ++++++++++--- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/frontend/src/api/leetcode-dashboard.tsx b/frontend/src/api/leetcode-dashboard.tsx index 9d7e722fab..1dd311356c 100644 --- a/frontend/src/api/leetcode-dashboard.tsx +++ b/frontend/src/api/leetcode-dashboard.tsx @@ -3,11 +3,9 @@ import { QuestionFull, NewQuestionData, } from "@/types/find-match"; -import * as dotenv from "dotenv"; - -dotenv.config(); const QUESTION_SERVICE = + process.env.NEXT_PUBLIC_QUESTION_SERVICE ?? "https://question-service-598285527681.us-central1.run.app/api"; export const createSingleLeetcodeQuestion = async ( diff --git a/frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx b/frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx index 5a3daf5552..1c717b8232 100644 --- a/frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx +++ b/frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx @@ -22,7 +22,11 @@ import MoonLoader from "react-spinners/MoonLoader"; import { createSingleLeetcodeQuestion } from "@/api/leetcode-dashboard"; import { topicsList } from "@/utils/constants"; -const AddQuestionDialog = () => { +interface AddQuestionDialogProps { + handleClose: () => void; +} + +const AddQuestionDialog = ({ handleClose }: AddQuestionDialogProps) => { const [isSubmitting, setIsSubmitting] = useState(false); const formSchema = z.object({ @@ -75,6 +79,7 @@ const AddQuestionDialog = () => { }) .finally(() => { setIsSubmitting(false); + handleClose(); }); } diff --git a/frontend/src/app/(auth)/leetcode-dashboard/EditQuestionDialog.tsx b/frontend/src/app/(auth)/leetcode-dashboard/EditQuestionDialog.tsx index ebe7b487ac..14a2d28764 100644 --- a/frontend/src/app/(auth)/leetcode-dashboard/EditQuestionDialog.tsx +++ b/frontend/src/app/(auth)/leetcode-dashboard/EditQuestionDialog.tsx @@ -27,6 +27,7 @@ import { capitalizeWords } from "@/utils/string_utils"; import { topicsList } from "@/utils/constants"; interface EditQuestionDialogProp { + handleClose: () => void; questionId: string; } @@ -44,7 +45,10 @@ const initialValues: EditQuestionValues = { questionDescription: "", }; -const EditQuestionDialog = ({ questionId }: EditQuestionDialogProp) => { +const EditQuestionDialog = ({ + questionId, + handleClose, +}: EditQuestionDialogProp) => { const [isSubmitting, setIsSubmitting] = useState(false); const [leetcodeData, setLeetcodeData] = useState(initialValues); @@ -107,6 +111,7 @@ const EditQuestionDialog = ({ questionId }: EditQuestionDialogProp) => { }); }) .finally(() => { + handleClose(); setIsSubmitting(false); }); } diff --git a/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx b/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx index 7cae625e30..e2f7ef98a5 100644 --- a/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx +++ b/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx @@ -72,7 +72,7 @@ const LeetcodeDashboard = () => { variants={modalAnimation} transition={{ duration: 0.3 }} > - + diff --git a/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx b/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx index 34bfbea082..2b8940caf4 100644 --- a/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx +++ b/frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx @@ -117,7 +117,11 @@ export function LeetcodeDashboardTable() { accessorKey: "category", header: () => Topics, cell: ({ row }) => { - return {row.getValue("category")}; + const categoryValue = row.getValue("category"); + const result: string = Array.isArray(categoryValue) + ? categoryValue.join(", ") + : String(categoryValue); + return {result}; }, }, { @@ -148,7 +152,10 @@ export function LeetcodeDashboardTable() { variants={modalAnimation} transition={{ duration: 0.3 }} > - +