Skip to content

Commit

Permalink
[ chore ] 빌드에러로 인한 커밋
Browse files Browse the repository at this point in the history
  • Loading branch information
myeongheonhong committed Dec 22, 2023
1 parent f1a7e49 commit a3348e9
Show file tree
Hide file tree
Showing 272 changed files with 26,543 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MAKE-A-WISH CLIENT
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;
};
44 changes: 44 additions & 0 deletions api/common/axios.ts
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');
}
}
},
);
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;
};
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}`,
};
30 changes: 30 additions & 0 deletions api/public.ts
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;
};
55 changes: 55 additions & 0 deletions api/user.ts
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;
};
Loading

1 comment on commit a3348e9

@vercel
Copy link

@vercel vercel bot commented on a3348e9 Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.