From cb33e44d9abaab3a8bfd82ff15b570f0564bbd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=84=EC=A1=B0?= Date: Mon, 9 Sep 2024 17:38:08 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20=ED=99=88=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=ED=95=9C=20=EC=9B=8C=ED=81=AC=EC=8A=A4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=EB=A1=9C=20=EC=9D=B4=EB=8F=99=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Home/index.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Home/index.tsx b/frontend/src/components/Home/index.tsx index 15adaf4..73267d5 100644 --- a/frontend/src/components/Home/index.tsx +++ b/frontend/src/components/Home/index.tsx @@ -1,4 +1,5 @@ import { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue, SelectGroup } from '../ui/select'; import GoogleLogo from '@/assets/icons/web_neutral_rd_ctn@1x.png'; @@ -8,9 +9,9 @@ interface HomeProps { } export default function Home({ isLoggedIn = false, setIsLoggedIn }: HomeProps) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [selectedWorkspace, setSelectedWorkspace] = useState(''); + const [, setSelectedWorkspace] = useState(''); const [loggedIn, setLoggedIn] = useState(isLoggedIn); + const navigate = useNavigate(); const workspaces = [ { id: 1, name: 'Workspace 1' }, @@ -20,12 +21,20 @@ export default function Home({ isLoggedIn = false, setIsLoggedIn }: HomeProps) { const handleGoogleSignIn = () => { console.log('구글로 계속하기'); - setLoggedIn(true); // 임시 코드 + setLoggedIn(true); if (setIsLoggedIn) { setIsLoggedIn(true); } }; + const handleWorkspaceSelect = (value: string) => { + const selected = workspaces.find((workspace) => workspace.name === value); + if (selected) { + navigate(`/browse/${selected.id}`); + } + setSelectedWorkspace(value); + }; + return (
@@ -59,7 +68,7 @@ export default function Home({ isLoggedIn = false, setIsLoggedIn }: HomeProps) { /> ) : ( -