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
survey
Commits
1b9e1b61
Commit
1b9e1b61
authored
Jul 01, 2022
by
Lee SeoYeon
Browse files
signup 0701
parent
e528b930
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/package.json
View file @
1b9e1b61
...
...
@@ -32,6 +32,7 @@
"webpack-dev-server"
:
"^4.9.2"
},
"dependencies"
:
{
"axios"
:
"^0.27.2"
,
"bcryptjs"
:
"^2.4.3"
,
"cookie-parser"
:
"^1.4.6"
,
"react"
:
"^18.2.0"
,
...
...
frontend/src/auth/SignUp.tsx
View file @
1b9e1b61
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
// import axios from "axios";
type
SignUpProps
=
{};
...
...
@@ -7,45 +8,51 @@ export const SignUp = ({}: SignUpProps) => {
const
USER
=
{
name
:
""
,
email
:
""
,
password
:
"
2345
"
,
password2
:
"
1234
"
,
password
:
""
,
password2
:
""
,
};
// interface USER {
// name: "";
// email: "";
// password: "";
// password2: "";
// }
const
[
user
,
setUser
]
=
useState
(
USER
);
const
[
error
,
setError
]
=
useState
(
''
)
const
[
disabled
,
setDisabled
]
=
useState
(
false
)
const
[
success
,
setSuccess
]
=
useState
(
false
)
// const [user, setUser] = useState<USER>();
const
[
error
,
setError
]
=
useState
(
""
);
const
[
disabled
,
setDisabled
]
=
useState
(
false
);
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
useEffect
(()
=>
{
setDisabled
(
!
(
user
.
name
&&
user
.
email
&&
user
.
password
&&
user
.
password2
))
},
[
user
])
setDisabled
(
!
(
user
.
name
&&
user
.
email
&&
user
.
password
&&
user
.
password2
))
;
},
[
user
])
;
function
handleChange
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
{
const
{
name
,
value
}
=
event
.
target
setUser
({...
user
,
[
name
]:
value
})
const
{
id
,
value
}
=
event
.
target
;
setUser
({
...
user
,
[
id
]:
value
})
;
}
async
function
handleSubmit
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
event
.
preventDefault
();
try
{
// console.log('checkPassword:',checkPassword())
// const passwordMatch = checkPassword()
console
.
log
(
"
checkPassword:
"
,
passwordmatch
());
if
(
passwordmatch
())
{
// const res = await
userA
pi
.
signup
(
user)
// console.log(
'
서버연결됬나요
'
, res)
console
.
log
(
'
회원가입
'
)
setSuccess
(
true
)
setError
(
''
)
// const res = await
axios.post("/a
pi
/
signup
",
user)
;
// console.log(
"
서버연결됬나요
"
, res)
;
console
.
log
(
"
회원가입
"
);
setSuccess
(
true
)
;
setError
(
""
);
}
}
catch
(
error
)
{
console
.
log
(
'
에러발생
'
)
console
.
log
(
"
에러발생
"
);
// catchErrors(error, setError)
}
finally
{
// setLoading(false);
}
}
function
passwordmatch
()
{
if
(
user
.
password
!==
user
.
password2
)
{
alert
(
"
비밀번호가 일치하지않습니다
"
);
...
...
@@ -56,12 +63,13 @@ export const SignUp = ({}: SignUpProps) => {
return
true
;
}
}
if
(
success
)
{
alert
(
'
회원가입 되었습니다
'
)
navigate
(
`../`
)
alert
(
"
회원가입 되었습니다
"
);
navigate
(
`../`
)
;
}
// const { name, email, password, password2 } = user;
return
(
<
div
className
=
"flex justify-center mt-3"
>
<
div
className
=
"flex flex-col space-y-4 mt-5 text-xl font-bold"
>
...
...
@@ -111,7 +119,9 @@ export const SignUp = ({}: SignUpProps) => {
<
div
className
=
"text-center mt-3"
>
<
button
className
=
"bg-themeColor text-white border rounded w-100 py-2 px-3 mt-3"
type
=
"submit"
onClick
=
{
handleSubmit
}
disabled
=
{
disabled
}
>
회원가입
</
button
>
...
...
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