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
messenger
Commits
d80d2238
Commit
d80d2238
authored
Jan 15, 2021
by
Choi Ga Young
Browse files
세션스토리지
parent
5e028ffa
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/src/Components/Chat.js
View file @
d80d2238
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Form
,
Button
,
Row
}
from
'
react-bootstrap
'
;
import
{
Form
,
Button
,
Row
}
from
'
react-bootstrap
'
;
function
Chat
(
props
)
{
function
Chat
(
props
)
{
// const [username, setUsername] = useState('')
let
defaultname
=
sessionStorage
.
getItem
(
'
name
'
);
let
defaultname
=
sessionStorage
.
getItem
(
'
name
'
);
// const [newName, setNewName] = useState({ username: '' });
// const [state, setState] = useState(false);
function
handleChange
(
e
)
{
function
handleChange
(
e
)
{
e
.
preventDefault
()
e
.
preventDefault
()
...
@@ -18,26 +15,12 @@ function Chat(props) {
...
@@ -18,26 +15,12 @@ function Chat(props) {
props
.
sendMsg
(
e
)
props
.
sendMsg
(
e
)
}
}
// const saveChange = (e) => {
// const { name, value } = e.target
// setNewName({ ...newName, [name]: value })
// }
// const handleSubmit = (e) => {
// e.preventDefault()
// setState(true)
// }
return
(
return
(
<
div
className
=
"
chat
"
id
=
"
chat
"
style
=
{{
border
:
"
2px solid
"
,
height
:
"
300%
"
,
margin
:
"
1%
"
,
borderColor
:
"
#BDBDBD
"
}}
>
<
div
className
=
"
chat
"
id
=
"
chat
"
style
=
{{
border
:
"
2px solid
"
,
height
:
"
300%
"
,
margin
:
"
1%
"
,
borderColor
:
"
#BDBDBD
"
}}
>
<
Button
variant
=
"
light
"
onClick
=
{
props
.
handleChatc
}
>
{
`<`
}
<
/Button
>
<
Button
variant
=
"
light
"
onClick
=
{
props
.
handleChatc
}
>
{
`<`
}
<
/Button
>
<
Form
onSubmit
=
{
handleSubmit
}
>
<
Form
.
Control
name
=
'
newname
'
type
=
'
text
'
onChange
=
{
saveChange
}
/
>
<
Button
variant
=
"
primary
"
type
=
"
submit
"
>
전송
<
/Button
>
<
/Form
>
<
h2
>
현재
{
props
.
roomName
}
입니다
.
<
/h2
>
<
h2
>
현재
{
props
.
roomName
}
입니다
.
<
/h2
>
{
props
.
chatmsg
.
map
((
value
,
index
)
=>
(
{
props
.
chatmsg
.
map
((
value
,
index
)
=>
(
<
Row
key
=
{
index
}
className
=
'
ml-3
'
>
<
Row
key
=
{
index
}
className
=
'
ml-3
'
>
...
...
client/src/Pages/ProfilePage.js
View file @
d80d2238
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
import
ReactDOM
from
'
react-dom
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
{
Image
,
Button
,
Container
,
Form
,
FormControl
,
Navbar
,
Nav
,
Row
,
Col
,
Dropdown
,
Carousel
}
from
'
react-bootstrap
'
;
import
{
Image
,
Button
,
Container
,
Form
,
Row
,
Col
,
Dropdown
}
from
'
react-bootstrap
'
;
import
{
BrowserRouter
as
Router
,
Route
,
Redirect
,
Switch
,
Link
}
from
'
react-router-dom
'
;
import
{
BrowserRouter
as
Link
}
from
'
react-router-dom
'
;
import
axios
from
'
axios
'
import
axios
from
'
axios
'
import
userdefault
from
'
../Images/KakaoTalk_20201230_153151693.png
'
import
userdefault
from
'
../Images/KakaoTalk_20201230_153151693.png
'
...
@@ -27,7 +26,7 @@ function ProfilePage() {
...
@@ -27,7 +26,7 @@ function ProfilePage() {
async
function
getLoginedUser
()
{
//email로 db에서 찾아오기 ㅇㅇㅇㅇㅇ
async
function
getLoginedUser
()
{
//email로 db에서 찾아오기 ㅇㅇㅇㅇㅇ
const
userid
=
local
Storage
.
getItem
(
'
user
'
)
const
userid
=
session
Storage
.
getItem
(
'
user
Id
'
)
const
response
=
await
axios
.
post
(
`/users/
${
userid
}
`
,
{
'
email
'
:
userid
})
const
response
=
await
axios
.
post
(
`/users/
${
userid
}
`
,
{
'
email
'
:
userid
})
setUser
(
response
.
data
)
setUser
(
response
.
data
)
}
}
...
@@ -44,7 +43,7 @@ function ProfilePage() {
...
@@ -44,7 +43,7 @@ function ProfilePage() {
setUser
({
...
user
,
'
nickname
'
:
e
.
target
.
value
})
setUser
({
...
user
,
'
nickname
'
:
e
.
target
.
value
})
}
}
async
function
handleNicksave
()
{
async
function
handleNicksave
()
{
const
userid
=
local
Storage
.
getItem
(
'
user
'
)
const
userid
=
session
Storage
.
getItem
(
'
user
Id
'
)
await
axios
.
put
(
`/users/
${
userid
}
`
,
user
)
await
axios
.
put
(
`/users/
${
userid
}
`
,
user
)
}
}
...
@@ -81,13 +80,7 @@ function ProfilePage() {
...
@@ -81,13 +80,7 @@ function ProfilePage() {
}
}
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
localStorage
.
getItem
(
'
user
'
))
{
//id뿐만아니라 토큰같은거를 확인 못하나 + 이런식으로 확인해도 되는것도 맞나
getLoginedUser
()
getLoginedUser
()
}
else
{
alert
(
"
로그인 후 이용하세요
"
)
window
.
location
.
href
=
'
/login
'
}
},
[])
},
[])
return
(
return
(
...
...
client/src/index.js
View file @
d80d2238
...
@@ -23,9 +23,9 @@ ReactDOM.render(
...
@@ -23,9 +23,9 @@ ReactDOM.render(
<
Route
path
=
"
/login
"
component
=
{
LogInPage
}
/
>
<
Route
path
=
"
/login
"
component
=
{
LogInPage
}
/
>
<
Route
path
=
"
/signup
"
component
=
{
SignUpPage
}
/
>
<
Route
path
=
"
/signup
"
component
=
{
SignUpPage
}
/
>
<
Route
path
=
"
/profile
"
component
=
{
ProfilePage
}
/
>
<
Route
path
=
"
/profile
"
component
=
{
ProfilePage
}
/
>
{
/*
<PrivateRoute path="/profile">
<
PrivateRoute
path
=
"
/profile
"
>
<
ProfilePage
/>
<
ProfilePage
/>
</PrivateRoute>
*/
}
<
/PrivateRoute
>
<
/Switch
>
<
/Switch
>
<
/Router>
,
<
/Router>
,
...
...
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