Skip to content

Commit

Permalink
merge/feat: 회원가입 api
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-el-c authored Aug 14, 2024
2 parents e81e083 + 8d20f5b commit ccb36c9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# localhost ssl
cert/
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
},
"scripts": {
"start": "react-scripts start",
"start:mac": "HTTPS=true SSL_CRT_FILE=cert/localhost.pem SSL_KEY_FILE=cert/localhost-key.pem npm run start",
"start:windows": "set HTTPS=true&&set SSL_CRT_FILE=cert/localhost.pem&&set SSL_KEY_FILE=cert/localhost-key.pem&&npm run start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
2 changes: 1 addition & 1 deletion src/apis/auth/socialLogin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useQuery } from 'react-query';
import { useQuery } from 'react-query';
import instance from '../instance';
import { BaseResponse } from '../../types/BaseResponse';
import { LoginSuccess } from '../../types/auth/login';
Expand Down
7 changes: 5 additions & 2 deletions src/apis/auth/useSignUpMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useSignUpMutation = (prevUrl: string) => {
const mutation = useMutation({
mutationFn: async (data: FormData) => {
return await instance.post<BaseResponse<LoginSuccess>>(
`/user/singup`,
`/user/signup`,
data,
{
headers: { 'Content-Type': 'multipart/form-data' },
Expand All @@ -34,7 +34,10 @@ export const useSignUpMutation = (prevUrl: string) => {
instance.defaults.headers.common['Authorization'] =
`Bearer ${accessToken}`; //로그인 된 유저에 대하여 모든 api 호출에 accesstoken 포함시키는 코드
} else {
//TODO: 회원가입 오류
//회원가입 오류
console.log('회원가입 실패');
navigate(`${prevUrl === '/' ? prevUrl : prevUrl + '?authState=login'}`);
return;
}

if (prevUrl === '/') navigate('/timeline');
Expand Down
10 changes: 9 additions & 1 deletion src/apis/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ const instance = axios.create({
// 요청 인터셉터
instance.interceptors.request.use(
(config) => {
// console.log('axios config : ', config);
const state = useRegisterStore.getState();
if (
state.accessToken &&
state.accessToken !== null &&
state.accessToken !== ''
) {
config.headers['Authorization'] = `Bearer ${state.accessToken}`;
}
console.log('axios config : ', config);
return config;
},
(error) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/profile_setting/ProfileInfoSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ const ProfileInfoSetting = () => {

const formData = new FormData();
imgFile && formData.append('imageFile', imgFile);
const requestDTO = JSON.stringify({
const requestJson = JSON.stringify({
nickname: nickname,
profileId: id,
});
const requestDTO = new Blob([requestJson], { type: 'application/json' });
formData.append('requestDTO', requestDTO);

//TODO: 회원가입 api 연결
Expand Down

0 comments on commit ccb36c9

Please sign in to comment.