From dd861149914bf147184b43430982789162462581 Mon Sep 17 00:00:00 2001 From: wlren Date: Sun, 9 Oct 2022 19:38:05 +0800 Subject: [PATCH] [questions][ui] question page --- .../questions/QuestionsNavigation.ts | 6 +- .../src/pages/questions/[id]/[slug]/index.tsx | 117 ++++++++++++++---- apps/portal/src/pages/questions/index.tsx | 4 + apps/portal/src/utils/questions/constants.ts | 2 +- 4 files changed, 104 insertions(+), 25 deletions(-) diff --git a/apps/portal/src/components/questions/QuestionsNavigation.ts b/apps/portal/src/components/questions/QuestionsNavigation.ts index 21df89db..0c5a6c43 100644 --- a/apps/portal/src/components/questions/QuestionsNavigation.ts +++ b/apps/portal/src/components/questions/QuestionsNavigation.ts @@ -2,9 +2,9 @@ import type { ProductNavigationItems } from '~/components/global/ProductNavigati const navigation: ProductNavigationItems = [ { href: '/questions', name: 'Home' }, - { href: '#', name: 'My Lists' }, - { href: '#', name: 'My Questions' }, - { href: '#', name: 'History' }, + { href: '/questions', name: 'My Lists' }, + { href: '/questions', name: 'My Questions' }, + { href: '/questions', name: 'History' }, ]; const config = { diff --git a/apps/portal/src/pages/questions/[id]/[slug]/index.tsx b/apps/portal/src/pages/questions/[id]/[slug]/index.tsx index f5f8b0d0..9206091d 100644 --- a/apps/portal/src/pages/questions/[id]/[slug]/index.tsx +++ b/apps/portal/src/pages/questions/[id]/[slug]/index.tsx @@ -1,34 +1,109 @@ -import { Button, Collapsible, TextArea } from '@tih/ui'; +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 QuestionOverviewCard from '~/components/questions/card/QuestionOverviewCard'; import { SAMPLE_QUESTION } from '~/utils/questions/constants'; +import { useFormRegister } from '~/utils/questions/useFormRegister'; + +export type AnswerQuestionData = { + 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: AnswerQuestionData) => { + // eslint-disable-next-line no-console + console.log(data); + }; + return ( -
-
-

Question overview

- - -
Comment placeholder
-
-