Showing
19 changed files
with
159 additions
and
6 deletions
... | @@ -13,8 +13,11 @@ | ... | @@ -13,8 +13,11 @@ |
13 | "axios": "^0.21.1", | 13 | "axios": "^0.21.1", |
14 | "react": "^17.0.2", | 14 | "react": "^17.0.2", |
15 | "react-dom": "^17.0.2", | 15 | "react-dom": "^17.0.2", |
16 | + "react-router-dom": "^5.2.0", | ||
16 | "react-scripts": "4.0.3", | 17 | "react-scripts": "4.0.3", |
17 | "recoil": "^0.4.0", | 18 | "recoil": "^0.4.0", |
19 | + "recoil-persist": "^3.0.0", | ||
20 | + "styled-components": "^5.3.0", | ||
18 | "typescript": "^4.1.2", | 21 | "typescript": "^4.1.2", |
19 | "web-vitals": "^1.0.1" | 22 | "web-vitals": "^1.0.1" |
20 | }, | 23 | }, |
... | @@ -43,6 +46,8 @@ | ... | @@ -43,6 +46,8 @@ |
43 | ] | 46 | ] |
44 | }, | 47 | }, |
45 | "devDependencies": { | 48 | "devDependencies": { |
49 | + "@types/react-router-dom": "^5.1.8", | ||
50 | + "@types/styled-components": "^5.1.12", | ||
46 | "@typescript-eslint/eslint-plugin": "^4.29.1", | 51 | "@typescript-eslint/eslint-plugin": "^4.29.1", |
47 | "@typescript-eslint/parser": "^4.29.1", | 52 | "@typescript-eslint/parser": "^4.29.1", |
48 | "eslint": "^7.32.0", | 53 | "eslint": "^7.32.0", | ... | ... |
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | 2 | ||
3 | +import Router from 'views/Router'; | ||
4 | +import { RecoilRoot } from 'recoil'; | ||
5 | + | ||
3 | function App() { | 6 | function App() { |
4 | return ( | 7 | return ( |
5 | - <div> | 8 | + <RecoilRoot> |
6 | - For Manager Web | 9 | + <Router /> |
7 | - </div> | 10 | + </RecoilRoot> |
8 | ); | 11 | ); |
9 | } | 12 | } |
10 | 13 | ||
14 | +App.defaultProps = {}; | ||
15 | + | ||
11 | export default App; | 16 | export default App; | ... | ... |
1 | import { client } from "./client"; | 1 | import { client } from "./client"; |
2 | 2 | ||
3 | -export const authApi = { | 3 | +export default { |
4 | register : (Data : FormData) => { | 4 | register : (Data : FormData) => { |
5 | return client.post('/auth/register', Data); | 5 | return client.post('/auth/register', Data); |
6 | }, | 6 | }, | ... | ... |
1 | import { client } from "./client"; | 1 | import { client } from "./client"; |
2 | import { RecoilState } from "recoil"; | 2 | import { RecoilState } from "recoil"; |
3 | 3 | ||
4 | -export const doctorApi = { | 4 | +export default { |
5 | getPatientList : (token : RecoilState<any>) => { | 5 | getPatientList : (token : RecoilState<any>) => { |
6 | return client.get('/doctor/patient', { | 6 | return client.get('/doctor/patient', { |
7 | headers : { | 7 | headers : { | ... | ... |
web/src/api/api-manager.ts
0 → 100644
1 | import { client } from './client'; | 1 | import { client } from './client'; |
2 | import { RecoilState } from 'recoil'; | 2 | import { RecoilState } from 'recoil'; |
3 | 3 | ||
4 | -export const userApi = { | 4 | +export default { |
5 | getMyInfo : (token : RecoilState<any>) => { | 5 | getMyInfo : (token : RecoilState<any>) => { |
6 | return client.get('/user', { | 6 | return client.get('/user', { |
7 | headers : { | 7 | headers : { | ... | ... |
web/src/api/index.ts
0 → 100644
... | @@ -2,10 +2,13 @@ import React from 'react'; | ... | @@ -2,10 +2,13 @@ import React from 'react'; |
2 | import ReactDOM from 'react-dom'; | 2 | import ReactDOM from 'react-dom'; |
3 | import App from './App'; | 3 | import App from './App'; |
4 | import reportWebVitals from './reportWebVitals'; | 4 | import reportWebVitals from './reportWebVitals'; |
5 | +import { RecoilRoot } from 'recoil'; | ||
5 | 6 | ||
6 | ReactDOM.render( | 7 | ReactDOM.render( |
7 | <React.StrictMode> | 8 | <React.StrictMode> |
9 | + <RecoilRoot> | ||
8 | <App /> | 10 | <App /> |
11 | + </RecoilRoot> | ||
9 | </React.StrictMode>, | 12 | </React.StrictMode>, |
10 | document.getElementById('root') | 13 | document.getElementById('root') |
11 | ); | 14 | ); | ... | ... |
web/src/util/recoilUtil.ts
0 → 100644
1 | +import { atom } from 'recoil'; | ||
2 | +import { recoilPersist } from 'recoil-persist'; | ||
3 | + | ||
4 | +const { persistAtom } = recoilPersist(); | ||
5 | + | ||
6 | +export const token = atom({ | ||
7 | + key : 'token', | ||
8 | + default : null, | ||
9 | + effects_UNSTABLE : [persistAtom], | ||
10 | +}); | ||
11 | + | ||
12 | +export const userType = atom({ | ||
13 | + key : 'userType', | ||
14 | + default : 'NORMAL', | ||
15 | + effects_UNSTABLE : [persistAtom], | ||
16 | +}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/Router.tsx
0 → 100644
1 | +import React from "react"; | ||
2 | +import { BrowserRouter, Route, Switch } from 'react-router-dom'; | ||
3 | + | ||
4 | +import { LoginContainer } from "./login"; | ||
5 | +import { MainContainer } from "./main"; | ||
6 | + | ||
7 | +const Router = () => { | ||
8 | + return ( | ||
9 | + <BrowserRouter> | ||
10 | + <Switch> | ||
11 | + <Route exact path = '/' component = {MainContainer}/> | ||
12 | + <Route exact path = '/login' component = {LoginContainer}/> | ||
13 | + </Switch> | ||
14 | + </BrowserRouter> | ||
15 | + ) | ||
16 | +}; | ||
17 | + | ||
18 | +export default Router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/login/LoginContainer.tsx
0 → 100644
1 | +import React, { useState, useEffect } from 'react'; | ||
2 | +import { RouteComponentProps } from 'react-router-dom'; | ||
3 | + | ||
4 | +import LoginPresenter from './LoginPresenter'; | ||
5 | + | ||
6 | +import { authApi } from 'api'; | ||
7 | + | ||
8 | +type LoginProps = RouteComponentProps | ||
9 | + | ||
10 | +const LoginContainer = (props : LoginProps) => { | ||
11 | + return ( | ||
12 | + <LoginPresenter | ||
13 | + temp = {'hi'} | ||
14 | + /> | ||
15 | + ) | ||
16 | +}; | ||
17 | + | ||
18 | +export default LoginContainer; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/login/LoginPresenter.tsx
0 → 100644
1 | +import React from 'react'; | ||
2 | + | ||
3 | +import * as styled from './LoginStyled'; | ||
4 | + | ||
5 | +interface LoginProps { | ||
6 | + temp : string; | ||
7 | +} | ||
8 | + | ||
9 | +const LoginPresenter = (props : LoginProps) => { | ||
10 | + return ( | ||
11 | + <styled.Container> | ||
12 | + This is Login Page {props.temp} | ||
13 | + </styled.Container> | ||
14 | + ); | ||
15 | +}; | ||
16 | + | ||
17 | +export default LoginPresenter; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/login/LoginStyled.tsx
0 → 100644
web/src/views/login/index.tsx
0 → 100644
1 | +export { default as LoginContainer } from './LoginContainer'; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/main/MainContainer.tsx
0 → 100644
1 | +import React, { useState, useEffect } from 'react'; | ||
2 | +import { RouteComponentProps} from 'react-router-dom'; | ||
3 | + | ||
4 | +import MainPresenter from './MainPresenter'; | ||
5 | + | ||
6 | +import { useRecoilState, useRecoilValue } from 'recoil'; | ||
7 | +import * as recoilUtil from '../../util/recoilUtil'; | ||
8 | + | ||
9 | +import { doctorApi, managerApi, userApi, authApi } from 'api'; | ||
10 | + | ||
11 | + | ||
12 | +type MainProps = RouteComponentProps | ||
13 | + | ||
14 | +const MainContainer = (props : MainProps) => { | ||
15 | + | ||
16 | + const [token, setToken] = useRecoilState(recoilUtil.token); | ||
17 | + const userType = useRecoilValue(recoilUtil.userType); | ||
18 | + | ||
19 | + useEffect(() => { | ||
20 | + if (!token) { | ||
21 | + console.log('no Token'); | ||
22 | + } | ||
23 | + }, []); | ||
24 | + | ||
25 | + return ( | ||
26 | + <MainPresenter | ||
27 | + temp = {'hi'} | ||
28 | + /> | ||
29 | + ); | ||
30 | +}; | ||
31 | + | ||
32 | +export default MainContainer; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/main/MainPresenter.tsx
0 → 100644
1 | +import React from 'react'; | ||
2 | + | ||
3 | +import * as styled from './MainStyled'; | ||
4 | + | ||
5 | + | ||
6 | +interface MainProps { | ||
7 | + temp : string; | ||
8 | +} | ||
9 | + | ||
10 | +const MainPresenter = (props : MainProps) => { | ||
11 | + return ( | ||
12 | + <styled.Container> | ||
13 | + This is Main Page {props.temp} | ||
14 | + </styled.Container> | ||
15 | + ) | ||
16 | +}; | ||
17 | + | ||
18 | +export default MainPresenter; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/src/views/main/MainStyled.tsx
0 → 100644
web/src/views/main/index.tsx
0 → 100644
1 | +export { default as MainContainer } from './MainContainer'; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff could not be displayed because it is too large.
-
Please register or login to post a comment