Skip to content

Commit

Permalink
Merge pull request #300 from sharemindteam/feat/open_consult_share_294
Browse files Browse the repository at this point in the history
[Feature] 셰어 공개상담 개발 요청 사항 반영 / react-query 반영
  • Loading branch information
rmdnps10 authored Jun 15, 2024
2 parents 4129197 + 26f242a commit 031c353
Show file tree
Hide file tree
Showing 47 changed files with 1,461 additions and 619 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@mui/material": "^5.15.6",
"@mui/styled-engine-sc": "^6.0.0-alpha.13",
"@stomp/stompjs": "^7.0.0",
"@tanstack/react-query": "^5.40.1",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
Expand Down
8 changes: 8 additions & 0 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ import { BuyerOpenPaymentDetail } from 'pages/Buyer/BuyerOpenPaymentDetail';
import BuyerWriteOpenConsult from 'pages/Buyer/BuyerWriteOpenConsult';
import BuyerOpenConsultDetail from 'pages/Buyer/BuyerOpenConsultDetail';
import BuyerFinishPayment from 'pages/Buyer/BuyerFinishPayment';
import BuyerOpenConsultLikes from 'pages/Buyer/BuyerOpenConsultLikes';
import BuyerOpenConsultRecents from 'pages/Buyer/BuyerOpenConsultRecents';

const Router = () => {
return (
<Routes>
Expand All @@ -61,6 +64,11 @@ const Router = () => {
<Route path="/" element={<Navigate to="/share" />} />
<Route path="/consult" element={<BuyerConsult />} />
<Route path="/open-consult" element={<BuyerOpenConsult />} />
<Route path="/open-consult/likes" element={<BuyerOpenConsultLikes />} />
<Route
path="/open-consult/recents"
element={<BuyerOpenConsultRecents />}
/>
<Route path="/open-consult/:id" element={<BuyerOpenConsultDetail />} />
<Route path="/profile/:id" element={<BuyerCounselorProfile />} />
<Route path="/search" element={<BuyerSearch />} />
Expand Down
117 changes: 117 additions & 0 deletions src/api/axios.deprecated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { instance, publicInstance } from './axios';

//
//
//

export const getInstance = async (url: string, params?: any) => {
try {
const data = await instance.get(url, params);
return data;
} catch (error) {
return error;
}
};
export const postInstance = async (url: string, body: any, params?: any) => {
try {
const data = await instance.post(url, body, params);
return data;
} catch (error) {
return error;
}
};
export const putInstance = async (url: string, body: any, params: any) => {
try {
const data = await instance.put(url, body, params);
return data;
} catch (error) {
return error;
}
};

export const patchInstance = async (url: string, body?: any, params?: any) => {
try {
const data = await instance.patch(url, body, params);
return data;
} catch (error) {
return error;
}
};

export const deleteInstance = async (url: string, body?: any) => {
try {
const config = {
data: body,
};
const data = await instance.delete(url, config);
return data;
} catch (error) {
return error;
}
};

//
//
//

export const getPublicInstance = async (url: string, params?: any) => {
try {
const data = await publicInstance.get(url, params);
return data;
} catch (error) {
return error;
}
};
export const postPublicInstance = async (
url: string,
body: any,
params?: any,
) => {
try {
const data = await publicInstance.post(url, body, params);
return data;
} catch (error) {
return error;
}
};
export const putPublicInstance = async (
url: string,
body: any,
params: any,
) => {
try {
const data = await publicInstance.put(url, body, params);
return data;
} catch (error) {
return error;
}
};

export const patchPublicInstance = async (
url: string,
body?: any,
params?: any,
) => {
try {
const data = await publicInstance.patch(url, body, params);
return data;
} catch (error) {
return error;
}
};

export const deletePublicInstance = async (url: string, body?: any) => {
try {
const config = {
data: body,
};
const data = await publicInstance.delete(url, config);
return data;
} catch (error) {
return error;
}
};

//
//
//
149 changes: 51 additions & 98 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import axios from 'axios';
import { postPublicReissue, postReissue } from './post';
import { getCookie, setCookie } from 'utils/cookie';
// axios 인스턴스 생성

//
//axios instance that the token is required
//

export const instance = axios.create({
baseURL: process.env.REACT_APP_API_URL,
headers: {
Authorization: `${getCookie('accessToken')}`,
},
});

instance.interceptors.request.use((config) => {
const token = getCookie('accessToken');
config.headers.Authorization = token;
Expand All @@ -32,6 +37,7 @@ instance.interceptors.response.use(
const tokenResponse: any = await postReissue({
refreshToken: getCookie('refreshToken'),
});

if (tokenResponse.status === 200) {
const { accessToken, refreshToken } = tokenResponse.data;
setCookie('accessToken', accessToken, { path: '/' });
Expand All @@ -53,13 +59,17 @@ instance.interceptors.response.use(
},
);

// axios 인증 필요 없는 인스턴스 생성
//
// axios instance that the token is not required
//

export const publicInstance = axios.create({
baseURL: process.env.REACT_APP_API_URL,
headers: {
Authorization: `${getCookie('accessToken')}`,
},
});

publicInstance.interceptors.request.use((config) => {
const token = getCookie('accessToken');
config.headers.Authorization = token;
Expand Down Expand Up @@ -102,106 +112,49 @@ publicInstance.interceptors.response.use(
return Promise.reject(error);
},
);
export const getInstance = async (url: string, params?: any) => {
try {
const data = await instance.get(url, params);
return data;
} catch (error) {
return error;
}
};
export const postInstance = async (url: string, body: any, params?: any) => {
try {
const data = await instance.post(url, body, params);
return data;
} catch (error) {
return error;
}
};
export const putInstance = async (url: string, body: any, params: any) => {
try {
const data = await instance.put(url, body, params);
return data;
} catch (error) {
return error;
}
};

export const patchInstance = async (url: string, body?: any, params?: any) => {
try {
const data = await instance.patch(url, body, params);
return data;
} catch (error) {
return error;
}
};
//
//
//

export const deleteInstance = async (url: string, body?: any) => {
try {
const config = {
data: body,
};
const data = await instance.delete(url, config);
return data;
} catch (error) {
return error;
}
};
export const axiosGet = async (url: string, params?: any) =>
await instance.get(url, { params });

export const getPublicInstance = async (url: string, params?: any) => {
try {
const data = await publicInstance.get(url, params);
return data;
} catch (error) {
return error;
}
};
export const postPublicInstance = async (
url: string,
body: any,
params?: any,
) => {
try {
const data = await publicInstance.post(url, body, params);
return data;
} catch (error) {
return error;
}
};
export const putPublicInstance = async (
url: string,
body: any,
params: any,
) => {
try {
const data = await publicInstance.put(url, body, params);
return data;
} catch (error) {
return error;
}
};
export const axiosPost = async (url: string, body: any, params?: any) =>
await instance.post(url, body, { params });

export const axiosPut = async (url: string, body: any, params: any) =>
await instance.put(url, body, { params });

export const axiosPatch = async (url: string, body?: any, params?: any) =>
await instance.patch(url, body, { params });

export const patchPublicInstance = async (
url: string,
body?: any,
params?: any,
) => {
try {
const data = await publicInstance.patch(url, body, params);
return data;
} catch (error) {
return error;
}
export const axiosDelete = async (url: string, body?: any) => {
const config = {
data: body,
};
return await instance.delete(url, config);
};

export const deletePublicInstance = async (url: string, body?: any) => {
try {
const config = {
data: body,
};
const data = await publicInstance.delete(url, config);
return data;
} catch (error) {
return error;
}
//
//
//

export const axiosPublicGet = async (url: string, params?: any) =>
await instance.get(url, { params });

export const axiosPublicPost = async (url: string, body: any, params?: any) =>
await instance.post(url, body, { params });

export const axiosPublicPut = async (url: string, body: any, params: any) =>
await instance.put(url, body, { params });

export const axiosPublicPatch = async (url: string, body?: any, params?: any) =>
await instance.patch(url, body, { params });

export const axiosPublicDelete = async (url: string, body?: any) => {
const config = {
data: body,
};
return await instance.delete(url, config);
};
2 changes: 1 addition & 1 deletion src/api/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deleteInstance } from './axios';
import { deleteInstance } from './axios.deprecated';

//Auth Controller
export const deleteAuthQuit = async (body: any) =>
Expand Down
Loading

0 comments on commit 031c353

Please sign in to comment.