From a513e2dd5556e50e6a36389c3d00ce1d0c55931f Mon Sep 17 00:00:00 2001 From: ktmihs Date: Mon, 21 Nov 2022 17:47:35 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#4=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 회원가입 라우팅 처리해주기 --- frontend/src/component/Setting/index.tsx | 29 +++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/src/component/Setting/index.tsx b/frontend/src/component/Setting/index.tsx index fb0cb1f..e083f2e 100644 --- a/frontend/src/component/Setting/index.tsx +++ b/frontend/src/component/Setting/index.tsx @@ -9,6 +9,8 @@ import { } from './setting.styled'; import { ArrowButton, SignupButton } from '../Button'; import hair from './hair'; +import axios from 'axios'; +import { useNavigate } from 'react-router-dom'; type CarouselType = { hairIdx: number; @@ -38,11 +40,32 @@ const Carousel = ({ hairIdx, setHairIdx }: CarouselType) => { }; const Setting = () => { + const navigate = useNavigate(); + const [hairIdx, setHairIdx] = useState(0); - const signup = () => { - console.log('signup'); - console.log(hairIdx); + const signup = async () => { + const data = await axios({ + method: 'POST', + url: '/api/user', + data: { + signupData: { + nickname: 'ktmihsKakao', + characterName: 'longhair', + }, + }, + withCredentials: true, + }); + + if (data.status === 200) { + navigate('/'); + } else if (data.status === 400) { + console.log('validation error(4~12, 한글 영어 숫자만 가능)'); + } else if (data.status === 406) { + console.log('닉네임 중복!'); + } else { + console.log('모르겠어용'); + } }; return (