-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1a7e49
commit a3348e9
Showing
272 changed files
with
26,543 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MAKE-A-WISH CLIENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from 'axios'; | ||
|
||
//서버통신 함수 | ||
export const client = axios.create({ | ||
baseURL: process.env.NEXT_PUBLIC_BASE_URL, | ||
}); | ||
|
||
client.interceptors.request.use(function (config: any) { | ||
const token = localStorage.getItem('accessToken'); | ||
|
||
if (!token) { | ||
config.headers['accessToken'] = null; | ||
return config; | ||
} | ||
|
||
if (config.headers && token) { | ||
config.headers['Authorization'] = `Bearer ${token}`; | ||
return config; | ||
} | ||
return config; | ||
}); | ||
|
||
client.interceptors.response.use( | ||
function (response) { | ||
return response; | ||
}, | ||
async function (error) { | ||
if (error.response) { | ||
if (error.response.data.message === '유효하지 않은 토큰입니다.') { | ||
// alert('로그인 상태를 확인해주세요!'); | ||
// window.location.replace('/'); | ||
} else if (error.response.data.message === '유효하지 않은 소원 링크입니다.') { | ||
// 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'); | ||
} | ||
} | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PostPublicCakesResponseType, PublicWishesDataResponseType } from '@/types/api/response'; | ||
import { client } from './common/axios'; | ||
import { API_VERSION_01, PATH_PUBLIC } from './path'; | ||
import { PostPublicCakesRequestType } from '@/types/api/request'; | ||
import { getAccessToken } from '@/utils/common/token'; | ||
|
||
const ACCESS_TOKEN = getAccessToken(); | ||
|
||
export const getPublicWishes = async (wishId: string | string[] | undefined) => { | ||
const data = await client.get<PublicWishesDataResponseType>( | ||
`${API_VERSION_01}${PATH_PUBLIC.GET_WISHES_INFO(wishId)}`, | ||
); | ||
|
||
return data.data.data; | ||
}; | ||
|
||
export const postPublicCakes = async (parameter: PostPublicCakesRequestType) => { | ||
const data = await client.post<PostPublicCakesResponseType>( | ||
`${API_VERSION_01}${PATH_PUBLIC.CAKES}`, | ||
parameter, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${ACCESS_TOKEN}`, | ||
}, | ||
}, | ||
); | ||
|
||
return data.data.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { getAccessToken } from '@/utils/common/token'; | ||
import { client } from './common/axios'; | ||
import { API_VERSION_01, PATH_USER } from './path'; | ||
import { UseFormReturn } from 'react-hook-form'; | ||
|
||
import { UserAccountDataResponseType } from '@/types/api/response'; | ||
import { WishesDataInputType } from '@/types/wishesType'; | ||
|
||
const ACCESS_TOKEN = getAccessToken(); | ||
|
||
export const patchUserAccount = async ( | ||
methods: UseFormReturn<WishesDataInputType, any, undefined>, | ||
) => { | ||
const data = await client.put( | ||
`${API_VERSION_01}${PATH_USER.ACCOUNT}`, | ||
{ | ||
accountInfo: { | ||
name: methods.getValues('name'), | ||
bank: methods.getValues('bank'), | ||
account: methods.getValues('account'), | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${ACCESS_TOKEN}`, | ||
}, | ||
}, | ||
); | ||
return data; | ||
}; | ||
|
||
export const getUserAccount = async () => { | ||
const data = await client.get<UserAccountDataResponseType>( | ||
`${API_VERSION_01}${PATH_USER.ACCOUNT}`, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${ACCESS_TOKEN}`, | ||
}, | ||
}, | ||
); | ||
return data?.data.data; | ||
}; | ||
|
||
export const deleteUserInfo = async () => { | ||
const data = await client.delete(`${API_VERSION_01}${PATH_USER.DEFAULT}`, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${ACCESS_TOKEN}`, | ||
}, | ||
}); | ||
|
||
return data; | ||
}; |
Oops, something went wrong.
a3348e9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
make-a-wish-client-test – ./
make-a-wish-client-test.vercel.app
make-a-wish-client-test-makeawish.vercel.app
make-a-wish-client-test-git-develop-makeawish.vercel.app