Skip to content

Commit

Permalink
Merge pull request #166 from Make-A-Wish-Sopt/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
myeongheonhong committed Dec 22, 2023
2 parents 3882e7a + a3348e9 commit cfdfc3d
Show file tree
Hide file tree
Showing 199 changed files with 10,477 additions and 5,091 deletions.
17 changes: 17 additions & 0 deletions api/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { API_VERSION_01, PATH_AUTH } from './path';
import { client } from './common/axios';

export const postAuthKakao = async (code: string) => {
const data = await client.post(
`${API_VERSION_01}${PATH_AUTH.KAKAO}?redirectUri=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URI}`,
{},
{
headers: {
'Content-Type': 'application/json',
code: `${code}`,
},
},
);

return data.data.data;
};
35 changes: 35 additions & 0 deletions api/cakes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getAccessToken } from '@/utils/common/token';
import { client } from './common/axios';
import { API_VERSION_01, PATH_CAKES } from './path';

const ACCESS_TOKEN = getAccessToken();

/**
* 해당 소원에 대한 케이크 조회
*/
export const getCakesInfo = async (
wishId: string | string[] | undefined,
cakeId: string | string[] | undefined,
) => {
const data = await client.get(`${API_VERSION_01}${PATH_CAKES.GET_CAKES_INFO(wishId, cakeId)}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});

return data.data.data;
};

/**
* 해당 소원에 대한 모든 케이크 리스트 결과 조회
*/
export const getCakesResult = async (wishId: string | string[] | undefined) => {
const data = await client.get(`${API_VERSION_01}${PATH_CAKES.GET_CAKES_RESULT(wishId)}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
return data.data.data;
};
53 changes: 0 additions & 53 deletions api/cakes/cakesAPI.ts

This file was deleted.

13 changes: 6 additions & 7 deletions api/common/axios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PATH from '@/constant/path';
import axios from 'axios';

//서버통신 함수
Expand Down Expand Up @@ -28,17 +27,17 @@ client.interceptors.response.use(
async function (error) {
if (error.response) {
if (error.response.data.message === '유효하지 않은 토큰입니다.') {
alert('로그인 상태를 확인해주세요!');
window.location.replace('/');
// alert('로그인 상태를 확인해주세요!');
// window.location.replace('/');
} else if (error.response.data.message === '유효하지 않은 소원 링크입니다.') {
alert(error.response.data.message);
window.location.replace('/');
// alert(error.response.data.message);
// window.location.replace('/');
} else if (
error.response?.data?.message === '이미 진행 중인 소원 링크가 있습니다.' ||
error.response?.data?.message === '주간이 끝난 소원 링크입니다.'
) {
alert(error.response?.data?.message);
window.location.replace('/main');
// alert(error.response?.data?.message);
// window.location.replace('/main');
}
}
},
Expand Down
25 changes: 25 additions & 0 deletions api/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import axios from 'axios';
import { client } from './common/axios';
import { API_VERSION_01 } from './path';
import { getAccessToken } from '@/utils/common/token';

export const uploadPresignedURL = async (signedURL: string, file: File | Blob | null) => {
const data = await axios.put(signedURL, file, {
headers: {
'Content-Type': file?.type,
},
});

return data;
};

export const getPresignedURL = async (fileName: string | undefined) => {
const data = await client.get(`${API_VERSION_01}/file?fileName=${fileName}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getAccessToken()}`,
},
});

return data;
};
20 changes: 0 additions & 20 deletions api/letters/getCakeLetters.ts

This file was deleted.

16 changes: 0 additions & 16 deletions api/letters/getCakesCount.ts

This file was deleted.

20 changes: 0 additions & 20 deletions api/links/deleteWishLinks.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/links/getOneWish.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/links/getWishLinks.ts

This file was deleted.

19 changes: 0 additions & 19 deletions api/login/sendCodeToServer.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/main/getProgressData.ts

This file was deleted.

45 changes: 0 additions & 45 deletions api/mypage/mypageAPI.ts

This file was deleted.

41 changes: 41 additions & 0 deletions api/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const API_VERSION_01 = '/api/v1';

const PATH = {
auth: '/auth',
user: '/user',
wishes: '/wishes',
public: '/public',
cakes: '/cakes',
};

export const PATH_AUTH = {
TOKEN: `${PATH.auth}/token`,
KAKAO: `${PATH.auth}/kakao/callback`,
};

export const PATH_USER = {
DEFAULT: PATH.user,
ACCOUNT: `${PATH.user}/account`,
ACCOUNT_VERIFY: `${PATH.user}/verify-account`,
ABUSE: `${PATH.user}/abuse`,
};

export const PATH_WISHES = {
DEFAULT: PATH.wishes,
PROGRESS: `${PATH.wishes}/progress`,
GET_SINGLE_WISH_INFO: (wishId: string | string[] | undefined) => `${PATH.wishes}/${wishId}`,
PRESENT_LINK_INFO: `${PATH.wishes}/present/info`,
MAIN: `${PATH.wishes}/main`,
};

export const PATH_PUBLIC = {
CAKES: `${PATH.public}/cakes`,
GET_WISHES_INFO: (wishId: string | string[] | undefined) =>
`${PATH.public}${PATH.wishes}/${wishId}`,
};

export const PATH_CAKES = {
GET_CAKES_RESULT: (wishId: string | string[] | undefined) => `${PATH.cakes}/${wishId}`,
GET_CAKES_INFO: (wishId: string | string[] | undefined, cakeId: string | string[] | undefined) =>
`${PATH.cakes}/${wishId}/${cakeId}`,
};
Loading

0 comments on commit cfdfc3d

Please sign in to comment.