Toggle navigation
Toggle navigation
This project
Loading...
Sign in
황선혁
/
weather_chatbot
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
Eric Whale
2022-06-08 21:33:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
389bff1dd6c94b4058b6e10c8770146952489d0d
389bff1d
1 parent
6757a95c
Add users page
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
18 deletions
client/src/components/UserBox.jsx
client/src/routes/users.jsx
client/src/service/auth.js
client/src/styles/box.scss
client/src/components/UserBox.jsx
View file @
389bff1
import
dateFormat
from
"dateformat"
;
import
"../styles/box.scss"
;
function
UserBox
({
user
})
{
const
{
country
,
city
,
createdAt
,
email
,
username
}
=
user
;
const
dateTime
=
dateFormat
(
createdAt
);
return
(
<
div
className=
"userBox"
>
<
h1
>
{
user
.
username
}
</
h1
>
<
p
>
user info
</
p
>
<
div
>
chat!(chatting functionality)
</
div
>
<
h1
>
{
username
}
</
h1
>
<
div
>
<
p
>
Country :
{
country
}
</
p
>
<
p
>
City :
{
city
}
</
p
>
<
br
/>
<
p
>
Joined at :
{
dateTime
}
</
p
>
<
p
>
email :
{
email
}
</
p
>
</
div
>
</
div
>
);
}
...
...
client/src/routes/users.jsx
View file @
389bff1
import
axios
from
"axio
s"
;
import
"../styles/box.scs
s"
;
import
{
useState
,
useEffect
}
from
"react"
;
// components
import
Bottombar
from
"../components/Bottombar"
;
import
Topbar
from
"../components/Topbar"
;
import
UserBox
from
"../components/UserBox"
;
import
authService
from
"../service/auth"
;
const
Userroom
=
()
=>
{
const
[
users
,
setUsers
]
=
useState
(
null
);
const
[
users
,
setUsers
]
=
useState
(
[]
);
if
(
!
users
)
return
null
;
useEffect
(()
=>
{
async
function
fetchData
()
{
const
usersData
=
await
authService
.
handleGetAllUser
();
setUsers
(
usersData
);
}
fetchData
();
},
[]);
return
(
<
div
>
<
Topbar
/>
<
h1
>
User Room
</
h1
>
<
div
>
{
Array
.
isArray
(
users
)
?
users
.
map
((
user
,
i
)
=>
{
return
<
UserBox
key=
{
i
}
user=
{
user
}
/>;
})
:
""
}
<
div
className=
"usersBox"
>
{
!
users
?
""
:
users
.
map
((
user
,
index
)
=>
{
return
<
UserBox
key=
{
index
}
user=
{
user
}
/>;
})
}
</
div
>
<
Bottombar
/>
...
...
client/src/service/auth.js
View file @
389bff1
...
...
@@ -72,11 +72,21 @@ const handleGetUser = async (userId) => {
}
};
const
handleGetAllUser
=
async
()
=>
{
try
{
const
response
=
await
axios
.
get
(
"http://localhost:8080/api/users/all"
);
return
response
.
data
;
}
catch
(
err
)
{
console
.
log
(
err
);
}
};
const
authService
=
{
handleSignup
,
handleLogin
,
handleUserEdit
,
handleGetUser
,
handleGetAllUser
,
};
export
default
authService
;
...
...
client/src/styles/box.scss
View file @
389bff1
.userBox
,
.chatBox
{
margin
:
0
.3rem
1rem
;
border
:
0
.2rem
black
solid
;
border-radius
:
10px
;
.usersBox
{
margin-top
:
10vh
;
}
.userBox
{
margin
:
1rem
;
border
:
0
.2rem
black
solid
;
border-radius
:
10px
;
display
:
flex
;
flex-direction
:
row
;
justify-content
:
flex-start
;
align-items
:
center
;
font-size
:
1
.4rem
;
*
{
padding
:
0
.3rem
0
.5rem
;
...
...
Please
register
or
login
to post a comment