From ef875ac2c65fbb60368f04b93bc44c00f73e25cd Mon Sep 17 00:00:00 2001 From: wlren Date: Sun, 9 Oct 2022 21:57:18 +0800 Subject: [PATCH] [questions][chore] add dummy data, refactor --- .../answer/[answerId]/[answerSlug]/index.tsx | 115 ++++++++++++++++++ .../[questionSlug]}/index.tsx | 17 ++- apps/portal/src/utils/questions/constants.ts | 1 + apps/portal/src/utils/questions/withHref.tsx | 21 ++++ 4 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx rename apps/portal/src/pages/questions/{[id]/[slug] => [questionId]/[questionSlug]}/index.tsx (86%) create mode 100644 apps/portal/src/utils/questions/withHref.tsx 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 new file mode 100644 index 00000000..eea8f5cc --- /dev/null +++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx @@ -0,0 +1,115 @@ +import { useRouter } from 'next/router'; +import { useForm } from 'react-hook-form'; +import { ArrowSmallLeftIcon } from '@heroicons/react/24/outline'; +import { Button, Collapsible, Select, TextArea } from '@tih/ui'; + +import AnswerCard from '~/components/questions/card/AnswerCard'; +import FullQuestionCard from '~/components/questions/card/FullQuestionCard'; + +import { SAMPLE_QUESTION } from '~/utils/questions/constants'; +import { useFormRegister } from '~/utils/questions/useFormRegister'; + +export type AnswerData = { + answerContent: string; +}; + +export default function QuestionPage() { + const router = useRouter(); + const { + register: formRegister, + handleSubmit, + formState: { isDirty, isValid }, + } = useForm({ mode: 'onChange' }); + const register = useFormRegister(formRegister); + const question = SAMPLE_QUESTION; + + const handleBackNavigation = () => { + router.back(); + }; + + const handleSubmitAnswer = (data: AnswerData) => { + // eslint-disable-next-line no-console + console.log(data); + }; + + return ( +
+
+ +
+
+
+ +
+ +
Comment placeholder
+
+
+
+