Skip to content

Commit 395d852

Browse files
committed
new admin dashboard changes
2 parents 6dc6625 + 04adfc8 commit 395d852

File tree

6 files changed

+680
-126
lines changed

6 files changed

+680
-126
lines changed

src/Chart/ProgressBar.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
3+
interface ProgressBarProps {
4+
passedPercentage: number; // Percentage of passed logins
5+
failedPercentage: number; // Percentage of failed logins
6+
}
7+
8+
function ProgressBar({ passedPercentage, failedPercentage }: ProgressBarProps) {
9+
return (
10+
<div className="w-1/2 space-y-4">
11+
<div className="relative h-6 rounded-full overflow-hidden bg-gray-200 dark:bg-gray-700">
12+
<div
13+
className="absolute h-full bg-green-500 text-white text-center"
14+
style={{ width: `${passedPercentage}%` }}
15+
>
16+
{passedPercentage}%
17+
</div>
18+
<div
19+
className="absolute h-full bg-red-500 text-white text-center"
20+
style={{
21+
width: `${failedPercentage}%`,
22+
left: `${passedPercentage}%`,
23+
}}
24+
>
25+
{failedPercentage}%
26+
</div>
27+
</div>
28+
<div className="flex justify-between text-sm text-gray-600 dark:text-gray-300">
29+
<p className="text-sm text-gray-600 dark:text-gray-300">
30+
<span className="text-green-500 font-semibold">Green</span>: Passed
31+
Logins
32+
</p>
33+
<p className="text-sm text-gray-600 dark:text-gray-300">
34+
<span className="text-red-500 font-semibold">Red</span>: Failed Logins
35+
</p>
36+
</div>
37+
</div>
38+
);
39+
}
40+
41+
export default ProgressBar;

src/Chart/TeamChart.tsx

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import React from 'react';
2+
import { Line } from 'react-chartjs-2';
3+
import {
4+
Chart as ChartJS,
5+
CategoryScale,
6+
LinearScale,
7+
PointElement,
8+
LineElement,
9+
Title,
10+
Tooltip,
11+
Legend,
12+
} from 'chart.js';
13+
14+
ChartJS.register(
15+
CategoryScale,
16+
LinearScale,
17+
PointElement,
18+
LineElement,
19+
Title,
20+
Tooltip,
21+
Legend,
22+
);
23+
24+
interface TeamChartProps {
25+
timeframe?: 'daily' | 'weekly' | 'monthly';
26+
}
27+
28+
function TeamChart({ timeframe = 'daily' }: TeamChartProps) {
29+
const chartData = {
30+
daily: {
31+
labels: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
32+
datasets: [
33+
{
34+
label: 'Andela',
35+
data: [1, 3, 0, 2, 1, 3, 2],
36+
fill: false,
37+
borderColor: '#4F46E5',
38+
tension: 0.4,
39+
},
40+
],
41+
},
42+
weekly: {
43+
labels: [
44+
'03',
45+
'06',
46+
'09',
47+
'12',
48+
'15',
49+
'18',
50+
'21',
51+
'24',
52+
'27',
53+
'30',
54+
'31',
55+
'34',
56+
'37',
57+
'40',
58+
'43',
59+
'46',
60+
'49',
61+
'54',
62+
],
63+
datasets: [
64+
{
65+
label: 'Andela',
66+
data: [1, 3, 0, 2, 1, 3, 2, 0, 2, 1, 3, 0, 2, 1, 4, 1, 2, 4],
67+
fill: false,
68+
borderColor: '#4F46E5',
69+
tension: 0.4,
70+
},
71+
],
72+
},
73+
monthly: {
74+
labels: Array.from({ length: 31 }, (_, i) =>
75+
String(i + 1).padStart(2, '0'),
76+
),
77+
datasets: [
78+
{
79+
label: 'Andela',
80+
data: Array.from({ length: 31 }, () => Math.floor(Math.random() * 8)),
81+
fill: false,
82+
borderColor: '#4F46E5',
83+
tension: 0.4,
84+
},
85+
],
86+
},
87+
};
88+
89+
const options = {
90+
responsive: true,
91+
maintainAspectRatio: false,
92+
plugins: {
93+
legend: {
94+
position: 'bottom' as const,
95+
},
96+
tooltip: {
97+
mode: 'index' as const,
98+
intersect: false,
99+
},
100+
},
101+
scales: {
102+
y: {
103+
beginAtZero: true,
104+
grid: {
105+
color: '#D1D5DB',
106+
},
107+
ticks: {
108+
color: '#6B7280',
109+
},
110+
},
111+
x: {
112+
grid: {
113+
display: false,
114+
},
115+
ticks: {
116+
color: '#6B7280',
117+
},
118+
},
119+
},
120+
};
121+
122+
return (
123+
<div className="w-full max-w-4xl h-[60vh] max-h-[500px] mx-auto p-4 md:p-6 lg:p-8 bg-white dark:bg-gray-800 rounded-md shadow-md">
124+
<Line data={chartData[timeframe]} options={options} />
125+
</div>
126+
);
127+
}
128+
129+
export default TeamChart;

src/Chart/UsersChart.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ ChartJS.register(
2121
Legend,
2222
);
2323

24-
// eslint-disable-next-line react/function-component-definition
25-
const usersChart: React.FC = () => {
24+
function UsersChart() {
2625
const data = {
2726
labels: [
2827
'01',
@@ -83,6 +82,7 @@ const usersChart: React.FC = () => {
8382

8483
const options = {
8584
responsive: true,
85+
maintainAspectRatio: false,
8686
plugins: {
8787
legend: {
8888
position: 'bottom' as const,
@@ -104,10 +104,10 @@ const usersChart: React.FC = () => {
104104
};
105105

106106
return (
107-
<div className="w-full h-[300px]">
108-
<Line data={data} options={options} className="-ml-8" />
107+
<div className="w-full max-w-4xl h-[60vh] max-h-[500px] mx-auto p-4 md:p-6 lg:p-8 bg-white dark:bg-gray-800 rounded-md shadow-md">
108+
<Line data={data} options={options} />
109109
</div>
110110
);
111-
};
111+
}
112112

113-
export default usersChart;
113+
export default UsersChart;

0 commit comments

Comments
 (0)