generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…f-companies #999 fe analytics of companies
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ | |
.menu-section-element__active { | ||
font-weight: 600; | ||
} | ||
|
69 changes: 69 additions & 0 deletions
69
FrontEnd/src/pages/AdminPage/UserProfilesTable/ProfilesStatistics.jsx
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,69 @@ | ||
import axios from 'axios'; | ||
import useSWR from 'swr'; | ||
import { Descriptions } from 'antd'; | ||
import Loader from '../../../components/Loader/Loader'; | ||
import css from './ProfilesStatistics.module.css'; | ||
|
||
async function fetcher(url) { | ||
const response = await axios.get(url); | ||
return response.data; | ||
} | ||
|
||
function ProfilesStatistics() { | ||
const baseUrl = process.env.REACT_APP_BASE_API_URL; | ||
const url = `${baseUrl}/api/admin/profiles/statistics/`; | ||
const { data: statistics, error, isLoading } = useSWR(url, fetcher); | ||
|
||
const items = statistics | ||
? [ | ||
{ | ||
key: '1', | ||
label: 'Кількість зареєстрованих компаній', | ||
children: statistics.companies_count, | ||
}, | ||
{ | ||
key: '2', | ||
label: 'Кількість Інвесторів', | ||
children: statistics.investors_count, | ||
}, | ||
{ | ||
key: '3', | ||
label: 'Кількість Cтратапів', | ||
children: statistics.startups_count, | ||
}, | ||
{ | ||
key: '4', | ||
label: 'Кількість заблокованих компаній', | ||
children: statistics.blocked_companies_count, | ||
}, | ||
] | ||
: []; | ||
|
||
return isLoading ? ( | ||
<div className={css['loader-container']}> | ||
<Loader /> | ||
</div> | ||
) : error ? ( | ||
<div className={css['error']}>Не вдалося отримати статистику компаній</div> | ||
) : ( | ||
<Descriptions | ||
title="Статистика компаній" | ||
column={1} | ||
bordered | ||
size="small" | ||
items={items.map((item) => ({ | ||
...item, | ||
label: ( | ||
<span className={css['description-item-label']}>{item.label}</span> | ||
), | ||
children: ( | ||
<span className={css['description-item-content']}> | ||
{item.children} | ||
</span> | ||
), | ||
}))} | ||
/> | ||
); | ||
} | ||
|
||
export default ProfilesStatistics; |
24 changes: 24 additions & 0 deletions
24
FrontEnd/src/pages/AdminPage/UserProfilesTable/ProfilesStatistics.module.css
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,24 @@ | ||
.description-item-label { | ||
max-width: 150px; | ||
} | ||
|
||
.description-item-content { | ||
max-width: 200px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.error { | ||
color: #f5222d; | ||
background-color: #fff1f0; | ||
border: 1px solid #ffa39e; | ||
padding: 10px; | ||
border-radius: 4px; | ||
margin-top: 10px; | ||
} | ||
|
||
.loader-container { | ||
width: 200px; | ||
height: 300px; | ||
} |
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