Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#999 fe analytics of companies #1014

Merged
merged 7 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion FrontEnd/src/pages/AdminPage/Menu/Menu.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NavLink } from 'react-router-dom';
import { NavLink, useLocation } from 'react-router-dom';
import { useAuth } from '../../../hooks';
import ProfilesStatistics from '../UserProfilesTable/ProfilesStatistics';
import css from './Menu.module.css';

const MENU = [
Expand All @@ -25,6 +26,7 @@ const MENU = [
},
];


const SUPERUSER_MENU = [
{
id: 'am5',
Expand All @@ -41,6 +43,7 @@ const SUPERUSER_MENU = [

function Menu() {
const { isSuperUser } = useAuth();
const location = useLocation();

return (
<div className={css['menu-section']}>
Expand All @@ -53,6 +56,7 @@ function Menu() {
key={element.id} to={element.link}>{element.title}
</NavLink>
))}
{location.pathname === '/customadmin/profiles/' && <ProfilesStatistics />}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions FrontEnd/src/pages/AdminPage/Menu/Menu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
.menu-section-element__active {
font-weight: 600;
}

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;
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;
}
7 changes: 7 additions & 0 deletions FrontEnd/src/pages/CustomThemes/customAdminTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ const customAdminTheme = {
Table: {
lineWidth: 3,
colorPrimary: '#1f9a7c'
},
Carousel: {
colorBgContainer: '#B4D27A',
dotActiveWidth: 32,
dotWidth: 32,
dotHeight: 6,
lineHeight: 1,
}
},
};
Expand Down
Loading