[questions][chore] minor bug fixes

pull/355/head
wlren 3 years ago
parent efcc088abf
commit acaa5dbb92

@ -1,3 +1,4 @@
import React from 'react';
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
import type { ButtonSize } from '@tih/ui'; import type { ButtonSize } from '@tih/ui';
import { Button } from '@tih/ui'; import { Button } from '@tih/ui';
@ -11,6 +12,21 @@ export default function VotingButtons({
upvoteCount, upvoteCount,
size = 'md', size = 'md',
}: VotingButtonsProps) { }: 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 ( return (
<div className="flex flex-col items-center"> <div className="flex flex-col items-center">
<Button <Button
@ -19,6 +35,7 @@ export default function VotingButtons({
label="Upvote" label="Upvote"
size={size} size={size}
variant="tertiary" variant="tertiary"
onClick={handleUpvote}
/> />
<p>{upvoteCount}</p> <p>{upvoteCount}</p>
<Button <Button
@ -27,6 +44,7 @@ export default function VotingButtons({
label="Downvote" label="Downvote"
size={size} size={size}
variant="tertiary" variant="tertiary"
onClick={handleDownVote}
/> />
</div> </div>
); );

@ -41,6 +41,7 @@ type ActionButtonProps =
export type QuestionCardProps = ActionButtonProps & export type QuestionCardProps = ActionButtonProps &
StatisticsProps & StatisticsProps &
UpvoteProps & { UpvoteProps & {
company: string;
content: string; content: string;
href?: string; href?: string;
location: string; location: string;
@ -51,6 +52,7 @@ export type QuestionCardProps = ActionButtonProps &
}; };
export default function QuestionCard({ export default function QuestionCard({
company,
answerCount, answerCount,
content, content,
// ReceivedCount, // ReceivedCount,
@ -70,7 +72,8 @@ export default function QuestionCard({
{showVoteButtons && <VotingButtons upvoteCount={upvoteCount} />} {showVoteButtons && <VotingButtons upvoteCount={upvoteCount} />}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<div className="flex items-baseline justify-between"> <div className="flex items-baseline justify-between">
<div className="flex items-center gap-2 text-slate-500"> <div className="flex items-baseline gap-2 text-slate-500">
<h2 className="ml-1 text-lg">{company}</h2>
<Badge label={type} variant="primary" /> <Badge label={type} variant="primary" />
<p className="text-xs"> <p className="text-xs">
{timestamp} · {location} · {role} {timestamp} · {location} · {role}

@ -47,7 +47,7 @@ export default function QuestionPage() {
'questions.answers.comments.create', 'questions.answers.comments.create',
{ {
onSuccess: () => { onSuccess: () => {
utils.invalidateQuery([ utils.invalidateQueries([
'questions.answers.comments.getAnswerComments', 'questions.answers.comments.getAnswerComments',
{ answerId: answerId as string }, { answerId: answerId as string },
]); ]);

@ -29,6 +29,7 @@ export default function QuestionPage() {
const { const {
register: ansRegister, register: ansRegister,
handleSubmit, handleSubmit,
reset: resetAnswer,
formState: { isDirty, isValid }, formState: { isDirty, isValid },
} = useForm<AnswerQuestionData>({ mode: 'onChange' }); } = useForm<AnswerQuestionData>({ mode: 'onChange' });
const answerRegister = useFormRegister(ansRegister); const answerRegister = useFormRegister(ansRegister);
@ -86,6 +87,7 @@ export default function QuestionPage() {
content: data.answerContent, content: data.answerContent,
questionId: questionId as string, questionId: questionId as string,
}); });
resetAnswer();
}; };
const handleSubmitComment = (data: QuestionCommentData) => { const handleSubmitComment = (data: QuestionCommentData) => {

@ -179,7 +179,6 @@ export default function QuestionsHomePage() {
if (!loaded) { if (!loaded) {
return null; return null;
} }
const filterSidebar = ( const filterSidebar = (
<div className="divide-y divide-slate-200 px-4"> <div className="divide-y divide-slate-200 px-4">
<FilterSection <FilterSection
@ -282,6 +281,7 @@ export default function QuestionsHomePage() {
<QuestionOverviewCard <QuestionOverviewCard
key={question.id} key={question.id}
answerCount={question.numAnswers} answerCount={question.numAnswers}
company={question.company}
content={question.content} content={question.content}
href={`/questions/${question.id}/${createSlug( href={`/questions/${question.id}/${createSlug(
question.content, question.content,

Loading…
Cancel
Save