Skip to content

Commit 68797b7

Browse files
committed
Merge branch 'dev' of https://github.com/boostcampwm-2022/web27-Wabinar into feat/#43-S
2 parents e756ba7 + 60d0386 commit 68797b7

File tree

36 files changed

+623
-167
lines changed

36 files changed

+623
-167
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"classnames": "^2.3.2",
1515
"react": "^18.2.0",
1616
"react-dom": "^18.2.0",
17+
"react-loader-spinner": "^5.3.4",
1718
"react-router-dom": "^6.4.3"
1819
},
1920
"devDependencies": {

client/src/App.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1-
import { BrowserRouter, Routes, Route } from 'react-router-dom';
2-
3-
import { LoginPage, WorkspacePage } from './pages';
4-
import 'style/reset.scss';
1+
import { useState, useEffect } from 'react';
2+
import { Routes, Route, useNavigate } from 'react-router-dom';
3+
import { getAuth } from 'src/apis/auth';
4+
import UserContext, { User } from 'src/contexts/user';
5+
import { LoginPage, OAuthPage, WorkspacePage } from 'src/pages';
6+
import 'styles/reset.scss';
57

68
function App() {
9+
const [user, setUser] = useState<User>({ id: -1, name: '', avatarUrl: '' });
10+
const navigate = useNavigate();
11+
12+
const autoLogin = async () => {
13+
const currentUser = await getAuth();
14+
15+
if (!currentUser) return;
16+
17+
setUser(currentUser);
18+
navigate('/workspace');
19+
};
20+
21+
useEffect(() => {
22+
autoLogin();
23+
}, []);
24+
725
return (
8-
<BrowserRouter>
26+
<UserContext.Provider value={{ user, setUser }}>
927
<Routes>
1028
<Route path="/" element={<LoginPage />} />
29+
<Route path="/oauth" element={<OAuthPage />} />
1130
<Route path="/workspace" element={<WorkspacePage />} />
1231
</Routes>
13-
</BrowserRouter>
32+
</UserContext.Provider>
1433
);
1534
}
1635

client/src/apis/auth.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { http } from './http';
2+
import { OK, CREATED } from './http-status';
3+
4+
export const getAuth = async () => {
5+
const res = await http.get(`/auth`);
6+
7+
if (res.status !== OK) throw new Error();
8+
9+
return res.data;
10+
};
11+
12+
export const postAuthLogin = async (code: string) => {
13+
const res = await http.post(`/auth/login`, { code });
14+
15+
if (res.status !== CREATED) throw new Error();
16+
17+
return res.data;
18+
};
19+
20+
export const deleteAuthlogout = async () => {
21+
const res = await http.delete(`/auth/logout`);
22+
23+
if (res.status !== OK) throw new Error();
24+
25+
return;
26+
};

client/src/apis/http-status.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const OK = 200;
2+
export const CREATED = 201;
3+
4+
export const BAD_REQUEST = 400;
5+
export const UNAUTHORIZED = 401;
6+
7+
export const INTERNAL_SERVER_ERROR = 500;

client/src/apis/http.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import axios from 'axios';
2+
import env from 'config';
23

3-
const SERVER_URL = 'http://localhost:8080';
4+
const SERVER_PATH = env.SERVER_PATH;
45

56
export const http = axios.create({
6-
baseURL: SERVER_URL,
7+
baseURL: SERVER_PATH,
78
});

client/src/apis/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/src/apis/user.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { http } from './http';
2+
import { OK } from './http-status';
23

34
export const getWorkspaces = async (userId: number) => {
4-
try {
5-
const { data } = await http.get(`/user/${userId}/workspace`);
5+
const res = await http.get(`/user/${userId}/workspace`);
66

7-
return data;
8-
} catch (e) {
9-
return;
10-
}
7+
if (res.status !== OK) throw new Error();
8+
9+
return res.data;
1110
};

client/src/components/SelectModal/style.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'style/color.scss';
1+
@import 'styles/color.module.scss';
22

33
.modal {
44
z-index: 100;

client/src/components/WorkspaceList/style.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "../../styles/color.scss";
1+
@import 'styles/color.module.scss';
22

33
.workspace__container {
44
background-color: $primary-100;

client/src/components/WorkspaceModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function WorkspaceModal({
5252

5353
<Button
5454
text={btnText}
55-
isDisable={!inputValue.length}
55+
isDisabled={!inputValue.length}
5656
onClick={onClick}
5757
/>
5858
</>

0 commit comments

Comments
 (0)