-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/47/settings-page
- Loading branch information
Showing
9 changed files
with
11,798 additions
and
10,894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* eslint-disable no-useless-constructor */ | ||
import React, { useState, useEffect, useRef } from 'react' | ||
import { List, Loader, Pagination } from 'semantic-ui-react' | ||
import './style.scss' | ||
import unknownAvatar from '../../../static/unknown.png' | ||
|
||
import { Monitor, Server, AtSign, BarChart2, Home, Zap } from 'react-feather' | ||
|
||
function SettingsUsers() { | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [paginationPage, setPaginationPage] = useState(1) | ||
const [totalPaginationPages, setTotalPagionationPages] = useState(1) | ||
const [users, setUsers] = useState([]) | ||
|
||
useEffect(() => { | ||
document.title = 'Users – WorkGroup' | ||
|
||
loadUsers(1) | ||
}, []) | ||
|
||
const loadUsers = (page) => { | ||
setPaginationPage(page) | ||
setIsLoading(true) | ||
var tokenHeaders = new Headers() | ||
tokenHeaders.append('Authorization', 'Bearer ' + localStorage.getItem('token')) | ||
|
||
var requestOptions = { | ||
method: 'GET', | ||
headers: tokenHeaders, | ||
redirect: 'follow', | ||
} | ||
|
||
fetch(process.env.REACT_APP_API_URL + '/api/settings/users?page=' + page, requestOptions) | ||
.then((response) => response.json()) | ||
.then((result) => { | ||
setIsLoading(false) | ||
setTotalPagionationPages(result.total_pages) | ||
setUsers(result.users) | ||
console.log('res', result) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
}) | ||
} | ||
|
||
const handlePaginationChange = (event) => { | ||
loadUsers(Number.parseInt(event.target.getAttribute('value'))) | ||
} | ||
|
||
const getDate = (date) => { | ||
var newDate = new Date(date) | ||
|
||
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' } | ||
|
||
var todaysDate = new Date() | ||
|
||
let dateString = '' | ||
|
||
if (newDate.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) { | ||
todaysDate = new Date() | ||
newDate = new Date(date) | ||
let currentHours = newDate.getHours() | ||
currentHours = ('0' + currentHours).slice(-2) | ||
|
||
dateString = 'Today, ' + currentHours + ':' + (newDate.getMinutes() < 10 ? '0' : '') + newDate.getMinutes() | ||
} else { | ||
dateString = newDate.toLocaleDateString(process.env.REACT_APP_LOCALE, options) | ||
} | ||
|
||
return dateString | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="settings_content"> | ||
{isLoading ? ( | ||
<center className="settings_content_loader"> | ||
<Loader active>Loading Users...</Loader> | ||
</center> | ||
) : ( | ||
<> | ||
{users ? ( | ||
<> | ||
{users.map((member, index) => { | ||
return ( | ||
<List key={index} divided relaxed> | ||
<List.Item href={`/app/user/${member.email}`}> | ||
<List.Content> | ||
<div className="settings_user-avatar"> | ||
<img | ||
src={process.env.REACT_APP_API_URL + '/' + member.avatar.replace('./', '')} | ||
alt="" | ||
onError={(e) => { | ||
e.target.src = unknownAvatar | ||
}} | ||
/> | ||
</div> | ||
<List.Header as="a">{member.name}</List.Header> | ||
<List.Description as="a">{getDate(member.created_at)}</List.Description> | ||
</List.Content> | ||
</List.Item> | ||
</List> | ||
) | ||
})} | ||
<Pagination onPageChange={(event) => handlePaginationChange(event)} defaultActivePage={paginationPage} totalPages={totalPaginationPages} /> | ||
</> | ||
) : ( | ||
<center> | ||
<Zap size={35} strokeWidth={2} /> | ||
<br /> | ||
<span>There are no Members in this group.</span> | ||
</center> | ||
)} | ||
<br /> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default SettingsUsers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.settings_content { | ||
.settings_image_upload { | ||
border: 1px solid rgba(34, 36, 38, 0.15); | ||
border-radius: 10px; | ||
width: 100%; | ||
height: 70px; | ||
padding: 5px; | ||
object-fit: contain; | ||
cursor: pointer; | ||
} | ||
.item[role='listitem'] { | ||
padding: 10px !important; | ||
background: transparent; | ||
transition: all 0.15s; | ||
|
||
div.settings_user-avatar { | ||
width: 32px; | ||
height: 32px; | ||
float: left; | ||
border-radius: 100px; | ||
background: #ebebeb; | ||
margin-right: 10px; | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 100px; | ||
object-fit: cover; | ||
} | ||
} | ||
|
||
&:hover, | ||
&:focus { | ||
background: #f2f4f5; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
054b47e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: