Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
98bc3e3a
Commit
98bc3e3a
authored
Jan 11, 2021
by
이재연
Browse files
ㅇㅇㅇㅇㅇ
parent
a645a94a
Changes
2
Show whitespace changes
Inline
Side-by-side
client/src/Pages/Signup.js
View file @
98bc3e3a
...
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
...
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import
axios
from
'
axios
'
import
axios
from
'
axios
'
import
{
Form
,
Col
,
Container
,
Button
,
Row
,
Alert
}
from
'
react-bootstrap
'
import
{
Form
,
Col
,
Container
,
Button
,
Row
,
Alert
}
from
'
react-bootstrap
'
import
catchErrors
from
'
../utils/catchErrors
'
import
catchErrors
from
'
../utils/catchErrors
'
import
{
Redirect
}
from
'
react-router-dom
'
;
const
INIT_USER
=
{
const
INIT_USER
=
{
name
:
''
,
name
:
''
,
...
@@ -15,8 +16,8 @@ const INIT_USER = {
...
@@ -15,8 +16,8 @@ const INIT_USER = {
function
Signup
()
{
function
Signup
()
{
const
[
user
,
setUser
]
=
useState
(
true
)
const
[
user
,
setUser
]
=
useState
(
true
)
const
[
error
,
setError
]
=
useState
(
''
)
const
[
error
,
setError
]
=
useState
(
''
)
const
[
success
,
setSuccess
]
=
useState
(
false
)
const
[
validated
,
setValidated
]
=
useState
(
false
);
const
[
validated
,
setValidated
]
=
useState
(
false
);
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
const
{
name
,
value
}
=
event
.
target
const
{
name
,
value
}
=
event
.
target
...
@@ -39,30 +40,35 @@ const [validated, setValidated] = useState(false);
...
@@ -39,30 +40,35 @@ const [validated, setValidated] = useState(false);
setError
(
''
)
setError
(
''
)
const
response
=
await
axios
.
post
(
'
/api/users/signup
'
,
user
)
const
response
=
await
axios
.
post
(
'
/api/users/signup
'
,
user
)
console
.
log
(
response
.
data
)
console
.
log
(
response
.
data
)
setSuccess
(
true
)
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
}
}
function
checkPassword
(
event
)
{
function
checkPassword
(
event
){
const
p1
=
user
.
password
const
p1
=
user
.
password
const
p2
=
user
.
password2
const
p2
=
user
.
password2
if
(
p1
!==
p2
){
if
(
p1
!==
p2
)
{
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
alert
(
'
비밀번호가 일치하지 않습니다.
'
)
alert
(
'
비밀번호가 일치하지 않습니다.
'
)
return
false
return
false
}
else
{
}
else
{
return
true
return
true
}
}
}
}
if
(
success
)
{
alert
(
'
회원가입 되었습니다.
'
)
return
<
Redirect
to
=
'
/login
'
/>
}
return
(
return
(
<
div
>
<
div
>
<
Container
className
=
"
my-5
"
>
<
Container
className
=
"
my-5
"
>
...
@@ -186,7 +192,7 @@ const [validated, setValidated] = useState(false);
...
@@ -186,7 +192,7 @@ const [validated, setValidated] = useState(false);
<
/Row
>
<
/Row
>
<
/Container
>
<
/Container
>
<
/div
>
<
/div
>
)
)
}
}
export
default
Signup
export
default
Signup
\ No newline at end of file
server/.gitignore
View file @
98bc3e3a
node_modules
node_modules
package-lock.json
package-lock.json
uploads/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment