Skip to content

Commit

Permalink
new piechart and stats updated
Browse files Browse the repository at this point in the history
  • Loading branch information
RWEMAREMY authored and Bananayosostene committed Nov 14, 2024
1 parent 0643d85 commit 21063b0
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Chart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const BarChart: React.FC<Props> = () => {
],
datasets: [
{
label: 'Last 8 days',
label: 'Nova',
data: [12, 19, 3, 5, 2, 3, 12, 14, 5, 7, 9, 11],
backgroundColor: '#5A6ACF',
borderRadius: 0,
barThickness: 8,
},
{
label: 'Last Week',
label: 'Fighters',
data: [10, 15, 5, 8, 6, 9, 13, 9, 6, 8, 7, 10],
backgroundColor: '#D1D5DB',
borderRadius: 0,
Expand All @@ -63,7 +63,7 @@ const BarChart: React.FC<Props> = () => {
legend: {
position: 'bottom' as const,
labels: {
color: '#121212',
color: '#D1D5DB',
},
},
tooltip: {
Expand Down
96 changes: 96 additions & 0 deletions src/Chart/PieChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import React from 'react';
import { Doughnut } from 'react-chartjs-2';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';

ChartJS.register(ArcElement, Tooltip, Legend);

// eslint-disable-next-line react/function-component-definition
const PieChart: React.FC = () => {
const data = {
labels: ['new pie chart'],
datasets: [
{
label: 'rates',
data: [30, 100],
backgroundColor: ['#4F46E5', '#A5B4FC'],
hoverOffset: 4,
},
],
};
const data2 = {
labels: ['new pie chart'],
datasets: [
{
label: 'rates',
data: [30, 70],
backgroundColor: ['#4F46E5', '#A5B4FC'],
hoverOffset: 4,
},
],
};
const data3 = {
labels: ['new pie chart'],
datasets: [
{
label: 'rates',
data: [60, 60],
backgroundColor: ['#4F46E5', '#A5B4FC'],
hoverOffset: 4,
},
],
};

const options = {
responsive: true,
cutout: '70%',
plugins: {
tooltip: {
callbacks: {
// eslint-disable-next-line func-names, object-shorthand
label: function (tooltipItem: any) {
return `${tooltipItem.label}: ${tooltipItem.raw}%`;
},
},
},
legend: {
display: false,
},
},
};

return (
<div className="flex flex-col items-center -ml-8 mb-8">
<div className="flex space-x-8">
<div className="relative w-[200px] h-[200px] bg-red-200 p-2 rounded">
<Doughnut data={data} options={options} />
<div className="absolute inset-0 flex items-center justify-center">
<div className="text-center">
<p className="text-2xl font-semibold text-gray-500">10</p>
</div>
</div>
<p className="text-center mt-2">New Invitations & Registration</p>
</div>
<div className="relative w-[200px] h-[200px] bg-green-200 p-2 rounded">
<Doughnut data={data2} options={options} />
<div className="absolute inset-0 flex items-center justify-center">
<div className="text-center">
<p className="text-2xl font-semibold text-gray-500">20</p>
</div>
</div>
<p className="text-center mt-2">Upcoming Events</p>
</div>
<div className="relative w-[200px] h-[200px] bg-yellow-200 p-2 rounded">
<Doughnut data={data3} options={options} />
<div className="absolute inset-0 flex items-center justify-center">
<div className="text-center">
<p className="text-2xl font-semibold text-gray-500">50</p>
</div>
</div>
<p className="text-center mt-2">Active& Progressive Tickets</p>
</div>
</div>
</div>
);
};

export default PieChart;
8 changes: 4 additions & 4 deletions src/Chart/AppointmentsChart.tsx → src/Chart/UsersChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ChartJS.register(
);

// eslint-disable-next-line react/function-component-definition
const AppointmentsChart: React.FC = () => {
const usersChart: React.FC = () => {
const data = {
labels: [
'01',
Expand Down Expand Up @@ -59,7 +59,7 @@ const AppointmentsChart: React.FC = () => {
],
datasets: [
{
label: 'Last days',
label: 'Andela',
data: [
1, 3, 0, 2, 1, 3, 2, 0, 2, 1, 3, 0, 2, 1, 4, 1, 2, 4, 7, 2, 3, 4, 4,
3, 8, 0, 3, 5, 7,
Expand All @@ -69,7 +69,7 @@ const AppointmentsChart: React.FC = () => {
tension: 0.4,
},
{
label: 'Last days',
label: 'NESA',
data: [
2, 3, 6, 4, 3, 4, 2, 1, 2, 6, 2, 2, 3, 2, 3, 5, 7, 2, 1, 2, 4, 6, 6,
1, 2, 3, 4, 5, 6.5,
Expand Down Expand Up @@ -110,4 +110,4 @@ const AppointmentsChart: React.FC = () => {
);
};

export default AppointmentsChart;
export default usersChart;
103 changes: 103 additions & 0 deletions src/components/AdminDashboardTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React from 'react';
import { FaEye } from 'react-icons/fa';

const DashboardTableDesign = () => {
const dummyData = [
{ team: 'Nova', logins: '2.4k', users: 45 },
{ team: 'Fighters', logins: '1.8k', users: 32 },
{ team: 'Bitcrafters', logins: '1.2k', users: 28},
{ team: 'Team1', logins: '3.1k', users: 52 },
{ team: 'Team2', logins: '0.9k', users: 19 },
];

return (
<div className="w-full max-w-7xl mx-auto px-6 space-y-4">
<div className="flex justify-between items-center mb-6">
<h2 className="text-xl font-semibold text-gray-200">Team Analytics</h2>
<div className="flex gap-3">
<input
type="search"
placeholder="Search teams..."
className="px-4 py-2 bg-gray-700 rounded-lg text-sm text-gray-200 border border-gray-600 focus:outline-none focus:border-blue-500"
/>
</div>
</div>

<div className="bg-gray-800 rounded-xl shadow-xl overflow-hidden border border-gray-700">
<div className="overflow-x-auto">
<table className="w-full table-fixed">
<thead>
<tr className="bg-gray-900">
<th className="w-[30%] px-6 py-4 text-left">
<div className="flex items-center gap-2 text-sm font-semibold text-gray-300">
Team Name
</div>
</th>
<th className="w-[25%] px-6 py-4 text-left">
<div className="flex items-center gap-2 text-sm font-semibold text-gray-300">
Logins
</div>
</th>
<th className="w-[25%] px-6 py-4 text-left">
<div className="flex items-center gap-2 text-sm font-semibold text-gray-300">
Users
</div>
</th>
<th className="w-[20%] px-10 py-4 text-left">
<div className="flex items-center gap-2 text-sm font-semibold text-gray-300">
Actions
</div>
</th>
</tr>
</thead>
<tbody>
{dummyData.map((row, index) => (
<tr
key={index}

Check failure on line 56 in src/components/AdminDashboardTable.tsx

View workflow job for this annotation

GitHub Actions / build

Do not use Array index in keys
className="border-t border-gray-700 hover:bg-gray-700/50 transition-colors"
>
<td className="px-6 py-4">
<div className="flex items-center gap-3">
<div className="w-2 h-2 rounded-full bg-blue-500"></div>
<span className="text-gray-200 font-medium">{row.team}</span>
</div>
</td>
<td className="px-6 py-4">
<div className="text-gray-300">{row.logins}</div>
</td>
<td className="px-6 py-4">
<div className="inline-flex items-center px-3 py-1 rounded-full bg-gray-700 text-gray-300">
{row.users}
</div>
</td>
<td className="px-6 py-4">
<button className="flex items-center justify-center gap-2 px-4 py-2 text-sm text-blue-400 bg-blue-500/10 rounded-full hover:bg-blue-500/20 transition-colors">

Check failure on line 74 in src/components/AdminDashboardTable.tsx

View workflow job for this annotation

GitHub Actions / build

Missing an explicit type attribute for button
<FaEye className="text-xs" />
View
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>

<div className="px-6 py-4 bg-gray-900 border-t border-gray-700 flex items-center justify-between">
<div className="text-sm text-gray-400">
Showing 5 of 12 teams
</div>
<div className="flex gap-2">
<button className="px-4 py-2 text-sm text-gray-300 bg-gray-800 rounded-lg hover:bg-gray-700 transition-colors">

Check failure on line 90 in src/components/AdminDashboardTable.tsx

View workflow job for this annotation

GitHub Actions / build

Missing an explicit type attribute for button
Previous
</button>
<button className="px-4 py-2 text-sm text-gray-300 bg-gray-800 rounded-lg hover:bg-gray-700 transition-colors">

Check failure on line 93 in src/components/AdminDashboardTable.tsx

View workflow job for this annotation

GitHub Actions / build

Missing an explicit type attribute for button
Next
</button>
</div>
</div>
</div>
</div>
);
};

export default DashboardTableDesign;
22 changes: 17 additions & 5 deletions src/pages/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { t } from 'i18next';
import { useTranslation } from 'react-i18next';
import { useMutation } from '@apollo/client';
import { toast } from 'react-toastify';
import PieChart from '../Chart/PieChart';
import BarChart from '../Chart/BarChart';
import AppointmentsChart from '../Chart/AppointmentsChart';
import UsersChart from '../Chart/usersChart';
// eslint-disable-next-line import/no-useless-path-segments
import useDocumentTitle from '../hook/useDocumentTitle';
import Comingsoon from './Comingsoon';
import Button from '../components/Buttons';
import { UserContext } from '../hook/useAuth';
import { INVITE_USER_MUTATION } from '../Mutations/manageStudentMutations';
import { FaEye } from 'react-icons/fa';
import DashboardTableDesign from '../components/AdminDashboardTable';

function SupAdDashboard() {
function AdminDashboard() {
const { user } = useContext(UserContext);
const { t }: any = useTranslation();

Expand All @@ -25,7 +28,6 @@ function SupAdDashboard() {
const inviteModel = () => {
const newState = !inviteTraineeModel;
setInviteTraineeModel(newState);
// this is true
};

const [inviteUser] = useMutation(INVITE_USER_MUTATION, {
Expand Down Expand Up @@ -125,11 +127,14 @@ function SupAdDashboard() {
</div>
<div className="flex flex-col grow bg-light-bg dark:bg-dark-frame-bg">
<div className="flex flex-col justify-between">
<div className="w-[80%] h-[100%] pl-[210px] pb-8 flex flex-row ">
<PieChart />
</div>
<div className="w-[80%] h-[100%] pl-[90px] pb-8 flex flex-row ">
<div className="flex flex-col justify-center">
<span className="mr-[80px] rotate-90 ">Users</span>
</div>
<AppointmentsChart />
<UsersChart />
</div>

<div className="w-[80%] h-[100%] pl-[90px] pb-8 flex flex-row ">
Expand All @@ -140,8 +145,15 @@ function SupAdDashboard() {
</div>
</div>
</div>
<div className="w-full ">
<DashboardTableDesign />
</div>
</>
);
}

export default SupAdDashboard;
export default AdminDashboard;




0 comments on commit 21063b0

Please sign in to comment.