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
bora-it
Commits
0d8bc28d
Commit
0d8bc28d
authored
Aug 09, 2021
by
우지원
Browse files
0809
parent
0e228dad
Changes
15
Show whitespace changes
Inline
Side-by-side
client/src/components/Header.js
View file @
0d8bc28d
...
...
@@ -2,7 +2,7 @@ import { Link } from 'react-router-dom'
import
{
handleLogout
}
from
'
../context/auth
'
const
Header
=
()
=>
{
const
id
=
local
Storage
.
getItem
(
'
user
'
);
const
id
=
session
Storage
.
getItem
(
'
user
'
);
return
(
<
div
>
<
form
...
...
client/src/components/Home/CreateRoom.js
View file @
0d8bc28d
...
...
@@ -3,7 +3,7 @@ import { Redirect } from "react-router-dom";
import
roomApi
from
"
../../apis/room.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
id
=
local
Storage
.
getItem
(
'
user
'
);
const
id
=
session
Storage
.
getItem
(
'
user
'
);
const
INIT_ROOM
=
{
name
:
''
,
profileimg
:
''
,
...
...
client/src/components/Home/HomeProfile.js
View file @
0d8bc28d
...
...
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
import
userApi
from
"
../../apis/user.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
userprofile
=
local
Storage
.
getItem
(
"
user
"
);
const
userprofile
=
session
Storage
.
getItem
(
"
user
"
);
const
INIT_USER
=
{
id
:
userprofile
,
email
:
""
,
...
...
client/src/components/Home/JoinRoom.js
View file @
0d8bc28d
...
...
@@ -3,7 +3,7 @@ import { Redirect } from "react-router-dom";
import
roomApi
from
"
../../apis/room.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
id
=
local
Storage
.
getItem
(
"
user
"
);
const
id
=
session
Storage
.
getItem
(
"
user
"
);
const
JoinRoom
=
()
=>
{
const
[
roomId
,
setRoomId
]
=
useState
(
""
);
...
...
client/src/components/Home/RoomSingle.js
View file @
0d8bc28d
...
...
@@ -4,7 +4,7 @@ import roomApi from "../../apis/room.api";
import
userApi
from
"
../../apis/user.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
id
=
local
Storage
.
getItem
(
"
user
"
);
const
id
=
session
Storage
.
getItem
(
"
user
"
);
const
INIT_ROOM
=
{
roomId
:
""
,
name
:
""
,
...
...
client/src/components/KakaoShareButton.js
View file @
0d8bc28d
...
...
@@ -13,7 +13,7 @@ const KakaoShareButton = (porps) => {
const
[
inviteperson
,
setProfile
]
=
useState
(
INIT_invite
);
const
[
error
,
setError
]
=
useState
(
""
);
const
{
roomId
}
=
useParams
();
const
invitepersonId
=
local
Storage
.
getItem
(
"
user
"
);
const
invitepersonId
=
session
Storage
.
getItem
(
"
user
"
);
async
function
getProfile
(
userID
)
{
try
{
...
...
client/src/components/Profile/Info.js
View file @
0d8bc28d
...
...
@@ -2,7 +2,7 @@ import userApi from "../../apis/user.api";
import
{
useEffect
,
useState
}
from
"
react
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
userprofile
=
local
Storage
.
getItem
(
"
user
"
);
const
userprofile
=
session
Storage
.
getItem
(
"
user
"
);
const
INIT_PROFILE
=
{
name
:
""
,
email
:
"
a
"
,
...
...
client/src/components/Profile/InfoUpdate.js
View file @
0d8bc28d
...
...
@@ -3,7 +3,7 @@ import React, { useEffect, useState } from "react";
import
userApi
from
"
../../apis/user.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
userprofile
=
local
Storage
.
getItem
(
"
user
"
);
const
userprofile
=
session
Storage
.
getItem
(
"
user
"
);
const
INIT_PROFILE
=
{
id
:
userprofile
,
name
:
""
,
...
...
client/src/components/Profile/Profile.js
View file @
0d8bc28d
...
...
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
import
userApi
from
"
../../apis/user.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
userprofile
=
local
Storage
.
getItem
(
"
user
"
);
const
userprofile
=
session
Storage
.
getItem
(
"
user
"
);
const
INIT_PROFILE
=
{
img
:
""
,
};
...
...
client/src/components/Room/ChannelList.js
View file @
0d8bc28d
...
...
@@ -15,7 +15,7 @@ const ChannelList = () => {
const
{
roomId
}
=
useParams
();
const
[
error
,
setError
]
=
useState
(
""
);
const
[
channel
,
setChannel
]
=
useState
([
INIT_CHANNEL
]);
const
id
=
local
Storage
.
getItem
(
'
user
'
);
const
id
=
session
Storage
.
getItem
(
'
user
'
);
async
function
getChannel
(
roomId
)
{
try
{
...
...
client/src/components/Room/ChannelSingle.js
View file @
0d8bc28d
...
...
@@ -9,7 +9,7 @@ const ChannelSingle = (props) => {
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
[
roomName
,
setRoomName
]
=
useState
(
''
);
const
{
roomId
,
channelId
}
=
useParams
();
const
userId
=
local
Storage
.
getItem
(
'
user
'
)
const
userId
=
session
Storage
.
getItem
(
'
user
'
)
async
function
joinChannel
(
e
)
{
...
...
client/src/components/Room/RightHamburger.js
View file @
0d8bc28d
...
...
@@ -5,6 +5,7 @@ import RoomApi from "../../apis/room.api";
import
catchErrors
from
"
../../context/catchError
"
;
import
KakaoShareButton
from
"
../KakaoShareButton
"
;
import
Roomnamechange
from
"
./Roomnamechange
"
;
import
UserApi
from
"
../../apis/user.api
"
;
const
INIT_ROOM
=
{
name
:
""
,
...
...
@@ -20,7 +21,7 @@ const RightHamburger = () => {
const
[
room
,
setRoom
]
=
useState
([
INIT_ROOM
]);
const
{
roomId
}
=
useParams
();
const
[
error
,
setError
]
=
useState
(
""
);
const
id
=
local
Storage
.
getItem
(
"
user
"
);
const
id
=
session
Storage
.
getItem
(
"
user
"
);
async
function
getRoom
(
roomId
)
{
try
{
...
...
@@ -40,7 +41,7 @@ const RightHamburger = () => {
async
function
exitRoom
()
{
console
.
log
(
"
id, roomid정보
"
,
id
,
roomId
);
try
{
const
data
=
await
RoomApi
.
exitRoom
({
id
,
roomId
});
await
RoomApi
.
exitRoom
({
id
,
roomId
});
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
...
...
@@ -66,6 +67,34 @@ const RightHamburger = () => {
}
}
async
function
exitChannel
()
{
try
{
const
data
=
await
UserApi
.
getUser
(
id
);
const
A
=
doubleJoinCheck
(
data
.
name
)
if
(
A
)
{
await
RoomApi
.
doubleJoin
({
roomId
:
roomId
,
index1
:
A
.
index1
,
index2
:
A
.
index2
,
joinChName
:
A
.
joinChName
})
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
}
function
doubleJoinCheck
(
e
)
{
for
(
const
index
in
channel
)
{
for
(
const
el
in
channel
[
index
].
joinUser
)
{
if
(
channel
[
index
].
joinUser
[
el
]
===
e
)
{
const
doublejoinCh
=
channel
[
index
].
channelName
const
A
=
{
index1
:
index
,
index2
:
el
,
joinChName
:
doublejoinCh
,
}
return
A
}
}
}
}
// console.log(channel)
useEffect
(()
=>
{
...
...
@@ -288,7 +317,7 @@ const RightHamburger = () => {
>
<
button
type
=
"
button
"
onClick
=
{
exitRoom
}
onClick
=
{
exitRoom
,
exitChannel
}
className
=
"
btn btn-primary
"
data
-
bs
-
dismiss
=
"
modal
"
>
...
...
client/src/context/auth.js
View file @
0d8bc28d
import
axios
from
'
axios
'
export
function
handleLogin
(
userId
)
{
local
Storage
.
setItem
(
"
user
"
,
userId
)
session
Storage
.
setItem
(
"
user
"
,
userId
)
}
export
async
function
handleLogout
()
{
alert
(
"
로그아웃되었습니다.
"
)
local
Storage
.
removeItem
(
"
user
"
)
session
Storage
.
removeItem
(
"
user
"
)
await
axios
.
get
(
'
/api/auth/logout
'
)
window
.
location
.
href
=
'
/
'
}
export
function
isAuthenticated
()
{
const
userId
=
local
Storage
.
getItem
(
'
loginStatus
'
)
const
userId
=
session
Storage
.
getItem
(
'
loginStatus
'
)
if
(
userId
)
{
return
userId
}
else
{
...
...
client/src/context/auth_context.js
View file @
0d8bc28d
...
...
@@ -36,7 +36,7 @@ const AuthProvider = ({ children }) => {
setError
(
""
);
setLoading
(
true
);
const
user
=
await
authApi
.
login
(
email
,
password
);
local
Storage
.
setItem
(
config
.
loginUser
,
JSON
.
stringify
(
user
));
session
Storage
.
setItem
(
config
.
loginUser
,
JSON
.
stringify
(
user
));
setUser
(
user
);
return
true
;
...
...
@@ -53,7 +53,7 @@ const AuthProvider = ({ children }) => {
setError
(
""
);
setUser
(
null
);
alert
(
"
로그아웃되었습니다.
"
);
local
Storage
.
removeItem
(
config
.
loginUser
);
session
Storage
.
removeItem
(
config
.
loginUser
);
setLoading
(
true
);
await
axios
.
get
(
`
${
baseUrl
}
/api/auth/logout`
);
}
catch
(
error
)
{
...
...
client/src/pages/InvitePage.js
View file @
0d8bc28d
import
Header
from
"
../components/Header
"
;
const
InvitePage
=
()
=>
{
const
usercheck
=
local
Storage
.
getItem
(
"
user
"
);
const
usercheck
=
session
Storage
.
getItem
(
"
user
"
);
function
goInvitedroom
()
{
let
check1
=
null
;
...
...
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