Skip to content

Commit

Permalink
Add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tingkai-mai committed Sep 29, 2024
1 parent a5f26a3 commit 419c36c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
4 changes: 1 addition & 3 deletions frontend/src/api/leetcode-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -75,6 +79,7 @@ const AddQuestionDialog = () => {
})
.finally(() => {
setIsSubmitting(false);
handleClose();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { capitalizeWords } from "@/utils/string_utils";
import { topicsList } from "@/utils/constants";

interface EditQuestionDialogProp {
handleClose: () => void;
questionId: string;
}

Expand All @@ -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<EditQuestionValues>(initialValues);
Expand Down Expand Up @@ -107,6 +111,7 @@ const EditQuestionDialog = ({ questionId }: EditQuestionDialogProp) => {
});
})
.finally(() => {
handleClose();
setIsSubmitting(false);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const LeetcodeDashboard = () => {
variants={modalAnimation}
transition={{ duration: 0.3 }}
>
<AddQuestionDialog />
<AddQuestionDialog handleClose={closeModal} />
</motion.div>
</Modal>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export function LeetcodeDashboardTable() {
accessorKey: "category",
header: () => <Cell>Topics</Cell>,
cell: ({ row }) => {
return <Cell>{row.getValue("category")}</Cell>;
const categoryValue = row.getValue("category");
const result: string = Array.isArray(categoryValue)
? categoryValue.join(", ")
: String(categoryValue);
return <Cell>{result}</Cell>;
},
},
{
Expand Down Expand Up @@ -148,7 +152,10 @@ export function LeetcodeDashboardTable() {
variants={modalAnimation}
transition={{ duration: 0.3 }}
>
<EditQuestionDialog questionId={questionId} />
<EditQuestionDialog
questionId={questionId}
handleClose={closeModal}
/>
</motion.div>
</Modal>
<Button variant={"ghost"} onClick={() => handleDelete(questionId)}>
Expand All @@ -161,7 +168,7 @@ export function LeetcodeDashboardTable() {
];

useEffect(() => {
getLeetcodeDashboardData().then((data) => setData(data));
getLeetcodeDashboardData().then((data) => setData(data.reverse()));
}, [refreshKey]);

const table = useReactTable({
Expand Down

0 comments on commit 419c36c

Please sign in to comment.