Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오인제
/
Tunnel
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정의왕
2021-12-02 17:28:26 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dbe76129f74235705e6cc95098ab0cbb554d927d
dbe76129
1 parent
6a0b271e
Set user-action & register form
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
38 deletions
turnel_FE/src/App.js
turnel_FE/src/_actions/types.js
turnel_FE/src/_actions/user_action.js
turnel_FE/src/_reducers/user_reducer.js
turnel_FE/src/component/views/LandingPage/LandingPage.js
turnel_FE/src/component/views/LoginPage/LoginPage.js
turnel_FE/src/component/views/MainPage/MainPage.js
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
turnel_FE/src/App.js
View file @
dbe7612
import
{
BrowserRouter
as
Router
,
Route
,
Routes
,
Link
}
from
"react-router-dom"
;
import
{
BrowserRouter
as
Router
,
Route
,
Routes
}
from
"react-router-dom"
;
import
MainPage
from
"./component/views/MainPage/MainPage"
;
import
LoginPage
from
"./component/views/LoginPage/LoginPage"
;
import
RegisterPage
from
"./component/views/RegisterPage/RegisterPage"
;
...
...
turnel_FE/src/_actions/types.js
View file @
dbe7612
export
const
LOGIN_USER
=
"login_user"
;
export
const
REGISTER_USER
=
"register_user"
;
\ No newline at end of file
...
...
turnel_FE/src/_actions/user_action.js
View file @
dbe7612
import
Axios
from
'axios'
;
import
{
LOGIN_USER
}
from
'./types'
;
import
{
LOGIN_USER
,
REGISTER_USER
}
from
'./types'
;
export
function
loginUser
(
dataToSubmit
)
{
...
...
@@ -10,3 +10,13 @@ export function loginUser(dataToSubmit) {
payload
:
request
}
}
export
function
registerUser
(
dataToSubmit
)
{
const
request
=
Axios
.
post
(
'/api/users/register'
,
dataToSubmit
)
.
then
(
response
=>
response
.
data
)
return
{
type
:
REGISTER_USER
,
payload
:
request
}
}
\ No newline at end of file
...
...
turnel_FE/src/_reducers/user_reducer.js
View file @
dbe7612
import
{
LOGIN_USER
LOGIN_USER
,
REGISTER_USER
}
from
'../_actions/types'
;
export
default
function
(
state
=
{},
action
)
{
...
...
@@ -7,7 +7,9 @@ export default function (state = {}, action) {
case
LOGIN_USER
:
return
{
...
state
,
loginSuccess
:
action
.
payload
}
break
;
case
REGISTER_USER
:
return
{...
state
,
registerSuccess
:
action
.
payload
}
break
;
default
:
return
state
;
}
...
...
turnel_FE/src/component/views/LandingPage/LandingPage.js
View file @
dbe7612
import
React
,
{
useEffect
}
from
'react'
import
axios
from
'axios'
import
React
from
'react'
//
import axios from 'axios'
// import { response } from 'express'
function
LandingPage
()
{
useEffect
(()
=>
{
axios
.
get
(
'/api/hello'
)
.
then
(
response
=>
console
.
log
(
response
.
data
))
},
[])
//
useEffect(() => {
//
axios.get('/api/hello')
//
.then(response => console.log(response.data))
//
}, [])
return
(
<
div
>
...
...
turnel_FE/src/component/views/LoginPage/LoginPage.js
View file @
dbe7612
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
Axios
from
'axios'
import
{
Link
}
from
"react-router-dom"
;
import
React
,
{
useState
}
from
"react"
;
import
"../style/LoginPage.scss"
;
import
{
Icon
,
Input
}
from
"semantic-ui-react"
import
{
useNavigate
}
from
"react-router-dom"
;
...
...
turnel_FE/src/component/views/MainPage/MainPage.js
View file @
dbe7612
import
{
Button
,
Grid
,
Image
,
Segment
}
from
"semantic-ui-react"
import
{
Button
}
from
"semantic-ui-react"
import
"../style/MainPage.scss"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
function
MainPage
()
{
const
navigate
=
useNavigate
();
...
...
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
View file @
dbe7612
import
React
,
{
use
Callback
,
use
State
}
from
"react"
;
import
React
,
{
useState
}
from
"react"
;
import
"../style/RegisterPage.scss"
;
import
{
Button
,
Icon
,
Input
}
from
"semantic-ui-react"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
registerUser
}
from
'../../../_actions/user_action'
function
RegisterPage
()
{
function
RegisterPage
(
props
)
{
const
dispatch
=
useDispatch
();
const
[
Id
,
setId
]
=
useState
(
""
);
const
[
Password
,
setPassword
]
=
useState
(
""
);
const
[
PasswordCheck
,
setPasswordCheck
]
=
useState
(
""
);
const
[
Personality
,
setPersonality
]
=
useState
(
""
);
const
[
PasswordError
,
setPasswordError
]
=
useState
(
false
);
const
onIdHandler
=
(
event
)
=>
{
setId
(
event
.
currentTarget
.
value
);
...
...
@@ -18,23 +20,32 @@ function RegisterPage() {
const
onPersonalityHandler
=
(
event
)
=>
{
setPersonality
(
event
.
currentTarget
.
value
);
};
const
onPasswordChkHandler
=
useCallback
(
(
event
)
=>
{
const
onPasswordChkHandler
=
(
event
)
=>
{
//비밀번호를 입력할때마다 password 를 검증하는 함수
setPasswordCheck
(
event
.
currentTarget
.
value
);
}
,[
PasswordCheck
])
;
const
onSubmitHandler
=
useCallback
(
(
event
)
=>
{
};
const
onSubmitHandler
=
(
event
)
=>
{
event
.
preventDefault
();
console
.
log
(
"ID"
,
Id
);
console
.
log
(
"Password"
,
Password
);
console
.
log
(
"MBTI"
,
Personality
);
if
(
Password
!==
PasswordCheck
)
{
return
setPasswordError
(
true
);
if
(
Password
!==
PasswordCheck
)
{
return
alert
(
'비밀번호가 일치하지 않습니다.'
)
}
else
{
return
setPasswordError
(
false
);
let
body
=
{
id
:
Id
,
password
:
Password
,
personality
:
Personality
}
dispatch
(
registerUser
(
body
))
.
then
(
response
=>
{
if
(
response
.
payload
.
success
)
{
props
.
history
.
push
(
'/login'
)
}
else
{
alert
(
'Failed to sign up'
)
}
})
}
},[
Password
,
PasswordCheck
]);
return
(
<
div
id
=
"Register"
>
<
div
className
=
"register-form"
>
...
...
@@ -42,9 +53,9 @@ function RegisterPage() {
<
h1
>
Tunnel
<
/h1
>
<
div
className
=
"input-area"
>
<
Input
icon
=
{
<
Icon
name
=
'at'
/>
}
icon
=
{
<
Icon
name
=
"id badge"
/>
}
iconPosition
=
'left'
placeholder
=
"
Email
"
placeholder
=
"
ID
"
type
=
"text"
value
=
{
Id
}
autoComplete
=
"off"
...
...
@@ -68,11 +79,7 @@ function RegisterPage() {
type
=
"password"
value
=
{
Password
}
autoComplete
=
"off"
onChange
=
{
onPasswordHandler
}
onFocus
=
{()
=>
setPasswordError
(
false
)}
/
>
{
PasswordError
&&
<
div
>
비밀번호
오류
<
/div
>
}
onChange
=
{
onPasswordHandler
}
/
>
<
/div
>
<
div
className
=
"input-area"
>
<
Input
...
...
@@ -82,8 +89,7 @@ function RegisterPage() {
type
=
"password"
value
=
{
PasswordCheck
}
autoComplete
=
"off"
onChange
=
{
onPasswordChkHandler
}
onFocus
=
{()
=>
setPasswordError
(
false
)}
/
>
onChange
=
{
onPasswordChkHandler
}
/
>
<
/div
>
<
div
className
=
"btn-area"
>
<
Button
className
=
'register-btn'
...
...
@@ -93,9 +99,7 @@ function RegisterPage() {
<
/div
>
<
/form
>
<
/div
>
<
/div
>
);
}
export
default
RegisterPage
;
...
...
Please
register
or
login
to post a comment