Skip to content

Commit 419c36c

Browse files
committed
Add fix
1 parent a5f26a3 commit 419c36c

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

frontend/src/api/leetcode-dashboard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import {
33
QuestionFull,
44
NewQuestionData,
55
} from "@/types/find-match";
6-
import * as dotenv from "dotenv";
7-
8-
dotenv.config();
96

107
const QUESTION_SERVICE =
8+
process.env.NEXT_PUBLIC_QUESTION_SERVICE ??
119
"https://question-service-598285527681.us-central1.run.app/api";
1210

1311
export const createSingleLeetcodeQuestion = async (

frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import MoonLoader from "react-spinners/MoonLoader";
2222
import { createSingleLeetcodeQuestion } from "@/api/leetcode-dashboard";
2323
import { topicsList } from "@/utils/constants";
2424

25-
const AddQuestionDialog = () => {
25+
interface AddQuestionDialogProps {
26+
handleClose: () => void;
27+
}
28+
29+
const AddQuestionDialog = ({ handleClose }: AddQuestionDialogProps) => {
2630
const [isSubmitting, setIsSubmitting] = useState(false);
2731

2832
const formSchema = z.object({
@@ -75,6 +79,7 @@ const AddQuestionDialog = () => {
7579
})
7680
.finally(() => {
7781
setIsSubmitting(false);
82+
handleClose();
7883
});
7984
}
8085

frontend/src/app/(auth)/leetcode-dashboard/EditQuestionDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { capitalizeWords } from "@/utils/string_utils";
2727
import { topicsList } from "@/utils/constants";
2828

2929
interface EditQuestionDialogProp {
30+
handleClose: () => void;
3031
questionId: string;
3132
}
3233

@@ -44,7 +45,10 @@ const initialValues: EditQuestionValues = {
4445
questionDescription: "",
4546
};
4647

47-
const EditQuestionDialog = ({ questionId }: EditQuestionDialogProp) => {
48+
const EditQuestionDialog = ({
49+
questionId,
50+
handleClose,
51+
}: EditQuestionDialogProp) => {
4852
const [isSubmitting, setIsSubmitting] = useState(false);
4953
const [leetcodeData, setLeetcodeData] =
5054
useState<EditQuestionValues>(initialValues);
@@ -107,6 +111,7 @@ const EditQuestionDialog = ({ questionId }: EditQuestionDialogProp) => {
107111
});
108112
})
109113
.finally(() => {
114+
handleClose();
110115
setIsSubmitting(false);
111116
});
112117
}

frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const LeetcodeDashboard = () => {
7272
variants={modalAnimation}
7373
transition={{ duration: 0.3 }}
7474
>
75-
<AddQuestionDialog />
75+
<AddQuestionDialog handleClose={closeModal} />
7676
</motion.div>
7777
</Modal>
7878
</div>

frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ export function LeetcodeDashboardTable() {
117117
accessorKey: "category",
118118
header: () => <Cell>Topics</Cell>,
119119
cell: ({ row }) => {
120-
return <Cell>{row.getValue("category")}</Cell>;
120+
const categoryValue = row.getValue("category");
121+
const result: string = Array.isArray(categoryValue)
122+
? categoryValue.join(", ")
123+
: String(categoryValue);
124+
return <Cell>{result}</Cell>;
121125
},
122126
},
123127
{
@@ -148,7 +152,10 @@ export function LeetcodeDashboardTable() {
148152
variants={modalAnimation}
149153
transition={{ duration: 0.3 }}
150154
>
151-
<EditQuestionDialog questionId={questionId} />
155+
<EditQuestionDialog
156+
questionId={questionId}
157+
handleClose={closeModal}
158+
/>
152159
</motion.div>
153160
</Modal>
154161
<Button variant={"ghost"} onClick={() => handleDelete(questionId)}>
@@ -161,7 +168,7 @@ export function LeetcodeDashboardTable() {
161168
];
162169

163170
useEffect(() => {
164-
getLeetcodeDashboardData().then((data) => setData(data));
171+
getLeetcodeDashboardData().then((data) => setData(data.reverse()));
165172
}, [refreshKey]);
166173

167174
const table = useReactTable({

0 commit comments

Comments
 (0)