Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSychev2005 committed Jan 10, 2025
1 parent 00d27d2 commit a433231
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions FrontEnd/src/pages/AdminPage/UserProfilesTable/ActivitiesBarChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,73 @@ import Loader from '../../../components/Loader/Loader';
import css from './ActivitiesBarChart.module.css';

ChartJS.register(
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend
);

async function fetcher(url) {
const response = await axios.get(url);
return response.data;
const response = await axios.get(url);
return response.data;
}

function ActivitiesBarChart() {
const baseUrl = process.env.REACT_APP_BASE_API_URL;
const activities_url = `${baseUrl}/api/admin/profiles/statistics-activities/`;
const { data: activities, error: activitiesError, isLoading: activitiesLoading } = useSWR(activities_url, fetcher);
const {data: activities, error: activitiesError, isLoading: activitiesLoading} = useSWR(activities_url, fetcher);
const chartData = activities
?{
labels: ['Виробники', 'Імпортери', 'Роздрібніки', 'HORECA', 'Інші'],
datasets: [
{
label: 'Типи компаній',
data: [
activities.manufacturers_count,
activities.importers_count,
activities.retail_networks_count,
activities.horeca_count,
activities.others_count
],
backgroundColor: [
'#87f3b0',
]
},
]
}: { labels: [], datasets: [] };
const options = {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Статистика по типам компаній',
? {
labels: ['Виробники', 'Імпортери', 'Роздрібніки', 'HORECA', 'Інші'],
datasets: [
{
label: 'Типи компаній',
data: [
activities.manufacturers_count,
activities.importers_count,
activities.retail_networks_count,
activities.horeca_count,
activities.others_count
],
backgroundColor: [
'#87f3b0',
]
},
]
} : {labels: [], datasets: []};
const options = {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Статистика по типам компаній',
},
},
},
maintainAspectRatio: false,
maintainAspectRatio: false,
};
return (
<div className={css['chart-container']}>
{activitiesLoading && (
<div className={css['loader-container']}>
<Loader/>
</div>
)
}
{activitiesError && (
<div className={css['error']}>Не вдалося отримати статистику компаній</div>
)
}
{!activitiesLoading && !activitiesError && (
<Bar options={options} data={chartData}/>
)
}
</div>
);
return (
<div className={css['chart-container']}>
{activitiesLoading && (
<div className={css['loader-container']}>
<Loader/>
</div>
)
}
{activitiesError && (
<div className={css['error']}>Не вдалося отримати статистику компаній</div>
)
}
{!activitiesLoading && !activitiesError && (
<Bar options={options} data={chartData}/>
)
}
</div>
);
}

export default ActivitiesBarChart;

0 comments on commit a433231

Please sign in to comment.