From acaa5dbb92dbae844e91e6dfa50cbf4161278da7 Mon Sep 17 00:00:00 2001 From: wlren Date: Mon, 10 Oct 2022 16:42:45 +0800 Subject: [PATCH] [questions][chore] minor bug fixes --- .../src/components/questions/VotingButtons.tsx | 18 ++++++++++++++++++ .../components/questions/card/QuestionCard.tsx | 5 ++++- .../answer/[answerId]/[answerSlug]/index.tsx | 2 +- .../[questionId]/[questionSlug]/index.tsx | 2 ++ apps/portal/src/pages/questions/index.tsx | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/apps/portal/src/components/questions/VotingButtons.tsx b/apps/portal/src/components/questions/VotingButtons.tsx index 74b9193e..51b96b34 100644 --- a/apps/portal/src/components/questions/VotingButtons.tsx +++ b/apps/portal/src/components/questions/VotingButtons.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'; import type { ButtonSize } from '@tih/ui'; import { Button } from '@tih/ui'; @@ -11,6 +12,21 @@ export default function VotingButtons({ upvoteCount, size = 'md', }: VotingButtonsProps) { + const handleUpvote = (event: React.MouseEvent) => { + event.preventDefault(); + + event.stopPropagation(); + console.log('upvote'); + }; + + const handleDownVote = (event: React.MouseEvent) => { + event.preventDefault(); + + event.stopPropagation(); + + console.log('downvote'); + }; + return (
); diff --git a/apps/portal/src/components/questions/card/QuestionCard.tsx b/apps/portal/src/components/questions/card/QuestionCard.tsx index 75e95dd2..b643f031 100644 --- a/apps/portal/src/components/questions/card/QuestionCard.tsx +++ b/apps/portal/src/components/questions/card/QuestionCard.tsx @@ -41,6 +41,7 @@ type ActionButtonProps = export type QuestionCardProps = ActionButtonProps & StatisticsProps & UpvoteProps & { + company: string; content: string; href?: string; location: string; @@ -51,6 +52,7 @@ export type QuestionCardProps = ActionButtonProps & }; export default function QuestionCard({ + company, answerCount, content, // ReceivedCount, @@ -70,7 +72,8 @@ export default function QuestionCard({ {showVoteButtons && }
-
+
+

{company}

{timestamp} · {location} · {role} diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx index aac0a7a2..d1c0e2a8 100644 --- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx +++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx @@ -47,7 +47,7 @@ export default function QuestionPage() { 'questions.answers.comments.create', { onSuccess: () => { - utils.invalidateQuery([ + utils.invalidateQueries([ 'questions.answers.comments.getAnswerComments', { answerId: answerId as string }, ]); diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx index f75fb1cb..29233351 100644 --- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx +++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx @@ -29,6 +29,7 @@ export default function QuestionPage() { const { register: ansRegister, handleSubmit, + reset: resetAnswer, formState: { isDirty, isValid }, } = useForm({ mode: 'onChange' }); const answerRegister = useFormRegister(ansRegister); @@ -86,6 +87,7 @@ export default function QuestionPage() { content: data.answerContent, questionId: questionId as string, }); + resetAnswer(); }; const handleSubmitComment = (data: QuestionCommentData) => { diff --git a/apps/portal/src/pages/questions/index.tsx b/apps/portal/src/pages/questions/index.tsx index 41e2cee7..d3d9efaa 100644 --- a/apps/portal/src/pages/questions/index.tsx +++ b/apps/portal/src/pages/questions/index.tsx @@ -179,7 +179,6 @@ export default function QuestionsHomePage() { if (!loaded) { return null; } - const filterSidebar = (