Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박민정
/
We-Shop
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박민정
2021-06-05 14:33:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cc486b3ed86d0312e8903c833be72e11c1cfbf01
cc486b3e
1 parent
37a759c3
[update] Update Login page (If login is success, go to main page)
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
boiler-plate/client/src/_reducers/index.js
boiler-plate/client/src/_reducers/user_reducer.js
boiler-plate/client/src/components/views/LoginPage/LoginPage.js
boiler-plate/client/src/_reducers/index.js
View file @
cc486b3
...
...
@@ -6,11 +6,11 @@
// ------------------------------------
// 이렇게 나눠진 다양한 reducer을 combineReducers을 통해 rootReducer에서 하나로 합쳐주는 기능을 만들 것임.
import
{
combineReducers
}
from
'redux'
;
//
import user from './user_reducer'; // user(회원가입, 로그인, 인증, 로그아웃 기능이 있음) reducer
import
user
from
'./user_reducer'
;
// user(회원가입, 로그인, 인증, 로그아웃 기능이 있음) reducer
// import comment from './comment_reducer'; // comment기능이 있을 때 reducer
const
rootReducer
=
combineReducers
(
{
user
})
// 다른 곳에서도 rootReducer을 쓸 수 있도록
...
...
boiler-plate/client/src/_reducers/user_reducer.js
View file @
cc486b3
...
...
@@ -10,8 +10,7 @@ export default function (prevState = {}, action) {
return
{...
prevState
,
loginSuccess
:
action
.
payload
}
// 위의 prevState를 그대로 가져오고,
// user_action.js에 있는 payload를 그대로 가져와서 return.
break
;
default
:
break
;
return
prevState
;
}
}
\ No newline at end of file
...
...
boiler-plate/client/src/components/views/LoginPage/LoginPage.js
View file @
cc486b3
...
...
@@ -4,15 +4,15 @@ import React from 'react'
import
{
useState
}
from
'react'
import
{
useDispatch
}
from
'react-redux'
;
import
{
loginUser
}
from
'../../../_actions/user_action'
import
{
withRouter
}
from
'react-router-dom'
;
function
LoginPage
()
{
function
LoginPage
(
props
)
{
// 이 로그인페이지 안에서 input에 타이핑을 함으로써 데이터를 변화시켜주므로 state 사용.
// 1-1. state을 사용하기 위해 state 만들어줌.
const
initialState
=
""
;
const
[
Email
,
setEmail
]
=
useState
(
initialState
);
// 1-2. email을 위한 state
const
[
Password
,
setPassword
]
=
useState
(
initialState
);
// 1-2. password를 위한 state
const
[
Email
,
setEmail
]
=
useState
(
""
);
// 1-2. email을 위한 state
const
[
Password
,
setPassword
]
=
useState
(
""
);
// 1-2. password를 위한 state
//1-3. 아래 input value에 넣어줌
// 2-1. 타이핑할 때 타이핑 하는 거 보이게 하도록 핸들러를 만들어줌
...
...
@@ -37,6 +37,15 @@ function LoginPage() {
}
dispatch
(
loginUser
(
logInfo
))
// _actions폴더 user_action.js에 있음
.
then
(
response
=>
{
if
(
response
.
payload
.
loginSuccess
)
props
.
history
.
push
(
'/'
);
else
alert
(
'Error'
);
})
}
return
(
...
...
@@ -58,4 +67,4 @@ function LoginPage() {
)
}
export
default
LoginPage
export
default
withRouter
(
LoginPage
)
...
...
Please
register
or
login
to post a comment