From 0028109960708709c1fa8b73bdae989a0adffc71 Mon Sep 17 00:00:00 2001 From: wlren Date: Sat, 8 Oct 2022 20:34:55 +0800 Subject: [PATCH] [questions][ui] change landing page to component --- .../questions/LandingComponent.tsx} | 54 ++++++++++++------- apps/portal/src/pages/questions/index.tsx | 21 ++++++-- 2 files changed, 53 insertions(+), 22 deletions(-) rename apps/portal/src/{pages/questions/landing.tsx => components/questions/LandingComponent.tsx} (65%) diff --git a/apps/portal/src/pages/questions/landing.tsx b/apps/portal/src/components/questions/LandingComponent.tsx similarity index 65% rename from apps/portal/src/pages/questions/landing.tsx rename to apps/portal/src/components/questions/LandingComponent.tsx index 6f80619c..97a3e647 100644 --- a/apps/portal/src/pages/questions/landing.tsx +++ b/apps/portal/src/components/questions/LandingComponent.tsx @@ -1,19 +1,37 @@ -import { useForm } from 'react-hook-form'; +import { useState } from 'react'; import { Button, Select } from '@tih/ui'; import NavBar from '~/components/questions/NavBar'; export type LandingQueryData = { - date: string; + company: string; location: string; questionType: string; }; -export default function LandingPage() { - const { register, handleSubmit } = useForm(); - const onSubmit = (data: LandingQueryData) => { - // eslint-disable-next-line no-console - console.log(data); +export type LandingComponentProps = { + handleLandingQuery: (data: LandingQueryData) => void; +}; + +export default function LandingComponent({ + handleLandingQuery, +}: LandingComponentProps) { + const [landingQueryData, setLandingQueryData] = useState({ + company: 'google', + location: 'singapore', + questionType: 'coding', + }); + + const handleChangeCompany = (company: string) => { + setLandingQueryData((prev) => ({ ...prev, company })); + }; + + const handleChangeLocation = (location: string) => { + setLandingQueryData((prev) => ({ ...prev, location })); + }; + + const handleChangeType = (questionType: string) => { + setLandingQueryData((prev) => ({ ...prev, questionType })); }; return ( @@ -29,13 +47,10 @@ export default function LandingPage() { Get to know the latest SWE interview questions asked by top companies

-
+

Find

in