Skip to content

Commit afbc13a

Browse files
ft(626): Admin Dashboard
1 parent 6ea7721 commit afbc13a

File tree

69 files changed

+6735
-2036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6735
-2036
lines changed

Diff for: package-lock.json

+22-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757
"apollo-upload-client": "^17.0.0",
5858
"autoprefixer": "^10.4.14",
5959
"axios": "^1.6.1",
60-
"chart.js": "^4.3.2",
60+
"chart.js": "^4.4.6",
6161
"cleave.js": "^1.6.0",
6262
"cloudinary": "^1.39.0",
6363
"cloudinary-react": "^1.8.1",
6464
"crypto-browserify": "^3.12.0",
6565
"date-fns": "^2.30.0",
66+
"dayjs": "^1.11.13",
6667
"dotenv": "^16.3.1",
6768
"express": "^4.18.2",
6869
"file-loader": "^6.2.0",
@@ -79,6 +80,7 @@
7980
"jsonwebtoken": "^9.0.1",
8081
"jwt-decode": "^3.1.2",
8182
"lottie-react": "^2.4.0",
83+
"lucide-react": "^0.453.0",
8284
"moment": "^2.29.4",
8385
"pnpm": "^8.6.11",
8486
"react-apexcharts": "^1.4.1",

Diff for: src/Chart/BarChart.tsx

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import React from 'react';
2+
import { Bar } from 'react-chartjs-2';
3+
import {
4+
Chart as ChartJS,
5+
CategoryScale,
6+
LinearScale,
7+
BarElement,
8+
Title,
9+
Tooltip,
10+
Legend,
11+
} from 'chart.js';
12+
import { useQuery } from '@apollo/client';
13+
import { GET_ALL_TEAMS } from '../queries/team.queries';
14+
import { FETCH_ALL_RATINGS } from '../queries/ratings.queries';
15+
16+
ChartJS.register(
17+
CategoryScale,
18+
LinearScale,
19+
BarElement,
20+
Title,
21+
Tooltip,
22+
Legend,
23+
);
24+
25+
interface Props {}
26+
27+
// eslint-disable-next-line react/function-component-definition
28+
const BarChart: React.FC<Props> = () => {
29+
const orgToken = localStorage.getItem('orgToken');
30+
const { data, loading, error } = useQuery(GET_ALL_TEAMS, {
31+
variables: {
32+
orgToken,
33+
},
34+
fetchPolicy: 'network-only',
35+
});
36+
37+
const {
38+
data: ratingsData,
39+
loading: ratingsLoading,
40+
error: ratingsError,
41+
} = useQuery(FETCH_ALL_RATINGS, {
42+
variables: {
43+
orgToken,
44+
},
45+
fetchPolicy: 'network-only',
46+
});
47+
48+
if (loading) return <p>Loading...</p>;
49+
if (error) return <p>Error: {error.message}</p>;
50+
51+
if (ratingsLoading) return <p>Loading ratings...</p>;
52+
if (ratingsError) return <p>Error loading ratings: {ratingsError.message}</p>;
53+
54+
const teamNames = data?.getAllTeams?.map(
55+
(team: { name: string }) => team.name,
56+
);
57+
const ratingsArray = ratingsData?.fetchAllRatings || [];
58+
59+
const professionalismData = ratingsArray.map(
60+
(rating: { professional_Skills: string }) =>
61+
parseFloat(rating.professional_Skills),
62+
);
63+
const qualityData = ratingsArray.map((rating: { quality: string }) =>
64+
parseFloat(rating.quality),
65+
);
66+
const quantityData = ratingsArray.map((rating: { quantity: string }) =>
67+
parseFloat(rating.quantity),
68+
);
69+
if (!teamNames || teamNames.length === 0) {
70+
return <p>No team data available.</p>;
71+
}
72+
73+
const datas = {
74+
labels: teamNames,
75+
datasets: [
76+
{
77+
label: 'Professionalism',
78+
data: professionalismData,
79+
backgroundColor: '#5A6ACF',
80+
borderRadius: 20,
81+
barThickness: 14,
82+
},
83+
{
84+
label: 'Quality',
85+
data: qualityData,
86+
backgroundColor: '#fcffa4',
87+
borderRadius: 20,
88+
barThickness: 14,
89+
},
90+
{
91+
label: 'Quantity',
92+
data: quantityData,
93+
backgroundColor: '#9f5233',
94+
borderRadius: 20,
95+
barThickness: 14,
96+
},
97+
],
98+
};
99+
100+
return (
101+
<div className="w-full h-[300px]">
102+
<Bar data={datas} options={{ responsive: true }} className="-ml-2" />
103+
</div>
104+
);
105+
};
106+
107+
export default BarChart;

0 commit comments

Comments
 (0)