Skip to content

Commit

Permalink
[feat] #4 회원가입 라우팅 처리
Browse files Browse the repository at this point in the history
- 회원가입 라우팅 처리해주기
  • Loading branch information
ktmihs committed Nov 21, 2022
1 parent 9e410e6 commit a513e2d
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions frontend/src/component/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit a513e2d

Please sign in to comment.