parent
8af58fe87a
commit
b9ff8157af
@ -0,0 +1,17 @@
|
|||||||
|
import type { QuestionsQuestionType } from '@prisma/client';
|
||||||
|
import { Badge } from '@tih/ui';
|
||||||
|
|
||||||
|
import { QUESTION_TYPES } from '~/utils/questions/constants';
|
||||||
|
|
||||||
|
export type QuestionTypeBadgeProps = {
|
||||||
|
type: QuestionsQuestionType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function QuestionTypeBadge({ type }: QuestionTypeBadgeProps) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
label={QUESTION_TYPES.find(({ value }) => value === type)!.label}
|
||||||
|
variant="info"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
@ -1,38 +1,11 @@
|
|||||||
import { format } from 'date-fns';
|
import type { AnswerCardProps } from './AnswerCard';
|
||||||
|
import AnswerCard from './AnswerCard';
|
||||||
|
|
||||||
import VotingButtons from '../VotingButtons';
|
export type FullAnswerCardProps = Omit<
|
||||||
|
AnswerCardProps,
|
||||||
|
'commentCount' | 'votingButtonsSize'
|
||||||
|
>;
|
||||||
|
|
||||||
export type FullAnswerCardProps = {
|
export default function FullAnswerCard(props: FullAnswerCardProps) {
|
||||||
authorImageUrl: string;
|
return <AnswerCard {...props} votingButtonsSize="md" />;
|
||||||
authorName: string;
|
|
||||||
content: string;
|
|
||||||
createdAt: Date;
|
|
||||||
upvoteCount: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function FullAnswerCard({
|
|
||||||
authorImageUrl,
|
|
||||||
authorName,
|
|
||||||
content,
|
|
||||||
createdAt,
|
|
||||||
upvoteCount,
|
|
||||||
}: FullAnswerCardProps) {
|
|
||||||
return (
|
|
||||||
<article className="flex gap-4 rounded-md border border-slate-300 bg-white p-4">
|
|
||||||
<VotingButtons upvoteCount={upvoteCount}></VotingButtons>
|
|
||||||
<div className="mt-1 flex flex-col gap-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<img
|
|
||||||
alt={`${authorName} profile picture`}
|
|
||||||
className="h-8 w-8 rounded-full"
|
|
||||||
src={authorImageUrl}></img>
|
|
||||||
<h1 className="font-bold">{authorName}</h1>
|
|
||||||
<p className="pt-1 text-xs font-extralight">
|
|
||||||
Posted on: {format(createdAt, 'Pp')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<p className="pl-1 pt-1">{content}</p>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
import withHref from '~/utils/questions/withHref';
|
||||||
|
|
||||||
|
import type { AnswerCardProps } from './AnswerCard';
|
||||||
|
import AnswerCard from './AnswerCard';
|
||||||
|
|
||||||
|
export type QuestionAnswerCardProps = Required<
|
||||||
|
Omit<AnswerCardProps, 'votingButtonsSize'>
|
||||||
|
>;
|
||||||
|
|
||||||
|
function QuestionAnswerCardWithoutHref(props: QuestionAnswerCardProps) {
|
||||||
|
return <AnswerCard {...props} votingButtonsSize="sm" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QuestionAnswerCard = withHref(QuestionAnswerCardWithoutHref);
|
||||||
|
export default QuestionAnswerCard;
|
Loading…
Reference in new issue