Skip to content

Commit 225dc81

Browse files
authored
Merge branch 'main' into 6-feat-meeting-page-상단바-생성
2 parents cd5fb3e + afa70c4 commit 225dc81

File tree

28 files changed

+316
-90
lines changed

28 files changed

+316
-90
lines changed

src/api/common/common.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Send from "@/api/send.ts";
2+
import { searchParams } from "@/types/searchParams";
3+
4+
export const getTest = () => {
5+
return Send({
6+
method: "get",
7+
url: "main/apiTest",
8+
});
9+
};
10+
11+
export const getSearch = (params: searchParams) => {
12+
return Send({
13+
method: "get",
14+
url: "main/search",
15+
params: params,
16+
});
17+
};

src/api/main/profile.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Send from "@/api/send.ts";
2+
3+
export const getProfile = () => {
4+
return Send({
5+
method: "get",
6+
url: "main/profile",
7+
});
8+
};

src/api/main/project.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import Send from "@/api/send.ts";
22
import { selectParams } from "@/types/selectParams";
33

4-
export const getTest = () => {
5-
return Send({
6-
method: "get",
7-
url: "main/apiTest",
8-
withCredentials: true,
9-
});
10-
};
11-
124
export const getProject = (params: selectParams) => {
135
return Send({
146
method: "get",
157
url: "main",
168
params: params,
17-
withCredentials: true,
189
});
1910
};

src/api/send.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ instance.interceptors.response.use(
2525
const originalRequest = error.config;
2626

2727
// accessToken 만료 (예: 401)
28-
if (error.response?.status === 503 && !originalRequest._retry) {
28+
if (error.response?.status === 401 && error.response?.data.message === 'AUTH_002' && !originalRequest._retry) {
2929
originalRequest._retry = true;
30+
3031
try {
31-
const res = await axios.post(`${import.meta.env.VITE_API_SERVER_URL}/auth/refresh`, {
32+
const res = await axios.post(`${import.meta.env.VITE_API_SERVER_URL}auth/refresh`, {
3233
refreshToken: getRefreshToken(),
3334
});
34-
const { accessToken, refreshToken } = res.data;
35+
const { accessToken, refreshToken } = res.data.data;
3536
setTokens(accessToken, refreshToken);
3637
originalRequest.headers.Authorization = `Bearer ${accessToken}`;
3738
return instance(originalRequest);
3839
} catch (e) {
40+
alert('로그인이 만료되었습니다.')
3941
clearTokens();
4042
window.location.href = "/";
4143
return Promise.reject(e);

src/api/splash/login.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@ export const postLogin = (loginData: LoginData) => {
99
withCredentials: true,
1010
});
1111
};
12+
13+
export const refresh = (data:any) => {
14+
return Send({
15+
method: "post",
16+
url: "auth/refresh",
17+
data: data,
18+
withCredentials: true,
19+
});
20+
};
21+
22+
export const logout = () => {
23+
return Send({
24+
method: "delete",
25+
url: "auth/logout"
26+
});
27+
};

src/assets/imgs/common/test.png

-14.4 KB
Binary file not shown.

src/assets/imgs/common/user.svg

Lines changed: 4 additions & 0 deletions
Loading

src/routes/Routes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BrowserRouter, Route, Routes } from "react-router-dom";
22

33
import ProjectPage from "@/views/main/page/ProjectPage";
4-
import SplashPage from "@/views/splash/page/SplashPage";
4+
import SplashRedirect from "./SplashRedirect";
55
import RecordPage from "@/views/main/page/RecordPage";
66
import SummaryPage from "@/views/main/page/SummaryPage";
77
import MeetingPage from "@/views/meeting/page/MeetingPage";
@@ -44,6 +44,7 @@ const Router = () => {
4444
</ProtectedRoute>
4545
}
4646
/>
47+
4748
</Routes>
4849
</BrowserRouter>
4950
);

src/routes/SplashRedirect.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Navigate } from "react-router-dom";
2+
import { isLoggedIn } from "@/utils/auth";
3+
import SplashPage from "@/views/splash/page/SplashPage";
4+
5+
const SplashRedirect = () => {
6+
if (isLoggedIn()) {
7+
return <Navigate to="/project" replace />;
8+
}
9+
return <SplashPage />;
10+
};
11+
12+
export default SplashRedirect;

src/types/profileData.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface profileData {
2+
memberId: number;
3+
name: string;
4+
email: string;
5+
imageUrl: string;
6+
time: string;
7+
date: string;
8+
}

0 commit comments

Comments
 (0)