[question][fix] use absolute path in back button

pull/411/head
Jeff Sieu 3 years ago
parent 3c3b219fda
commit 3d9f5dfedd

@ -1,5 +1,6 @@
import type { ComponentProps } from 'react'; import type { ComponentProps } from 'react';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { Popover } from '@headlessui/react';
import { Badge } from '@tih/ui'; import { Badge } from '@tih/ui';
type BadgeProps = ComponentProps<typeof Badge>; type BadgeProps = ComponentProps<typeof Badge>;
@ -22,7 +23,7 @@ export default function QuestionAggregateBadge({
return mostCommon; return mostCommon;
}, },
{ key: '', value: 0 }, { key: '', value: 0 },
), ),
[statistics], [statistics],
); );
@ -35,5 +36,16 @@ export default function QuestionAggregateBadge({
return `${mostCommonStatistic.key} (+${additionalStatisticCount})`; return `${mostCommonStatistic.key} (+${additionalStatisticCount})`;
}, [mostCommonStatistic, additionalStatisticCount]); }, [mostCommonStatistic, additionalStatisticCount]);
return <Badge label={label} {...badgeProps} />; return (
<Popover>
<Popover.Button>
<Badge label={label} {...badgeProps} />
</Popover.Button>
<Popover.Panel>
<div className="flex flex-col gap-2">
<h1>Hello</h1>
</div>
</Popover.Panel>
</Popover>
);
} }

@ -51,10 +51,6 @@ export default function QuestionPage() {
}, },
); );
const handleBackNavigation = () => {
router.back();
};
const handleSubmitComment = (data: AnswerCommentData) => { const handleSubmitComment = (data: AnswerCommentData) => {
resetComment(); resetComment();
addComment({ addComment({
@ -73,10 +69,11 @@ export default function QuestionPage() {
<Button <Button
addonPosition="start" addonPosition="start"
display="inline" display="inline"
href={`/questions/${router.query.questionId}/${router.query.questionSlug}`}
icon={ArrowSmallLeftIcon} icon={ArrowSmallLeftIcon}
label="Back" label="Back"
variant="secondary" variant="secondary"
onClick={handleBackNavigation}></Button> />
</div> </div>
<div className="flex w-full justify-center overflow-y-auto py-4 px-5"> <div className="flex w-full justify-center overflow-y-auto py-4 px-5">
<div className="flex max-w-7xl flex-1 flex-col gap-2"> <div className="flex max-w-7xl flex-1 flex-col gap-2">

@ -91,10 +91,6 @@ export default function QuestionPage() {
}, },
); );
const handleBackNavigation = () => {
router.back();
};
const handleSubmitAnswer = (data: AnswerQuestionData) => { const handleSubmitAnswer = (data: AnswerQuestionData) => {
addAnswer({ addAnswer({
content: data.answerContent, content: data.answerContent,
@ -121,10 +117,11 @@ export default function QuestionPage() {
<Button <Button
addonPosition="start" addonPosition="start"
display="inline" display="inline"
href="/questions"
icon={ArrowSmallLeftIcon} icon={ArrowSmallLeftIcon}
label="Back" label="Back"
variant="secondary" variant="secondary"
onClick={handleBackNavigation}></Button> />
</div> </div>
<div className="flex w-full justify-center overflow-y-auto py-4 px-5"> <div className="flex w-full justify-center overflow-y-auto py-4 px-5">
<div className="flex max-w-7xl flex-1 flex-col gap-2"> <div className="flex max-w-7xl flex-1 flex-col gap-2">

Loading…
Cancel
Save