From b3c07fd9f1664dda4f16357aaca74dff8226401d Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Thu, 1 Aug 2024 17:21:25 +0530 Subject: updated project --- panel/src/pages/Dashboard.jsx | 39 +++++++++++++++------ panel/src/pages/ManageAds.jsx | 80 +++++++++++++++++++++++-------------------- panel/src/pages/Roles.jsx | 26 ++++++++------ 3 files changed, 87 insertions(+), 58 deletions(-) (limited to 'panel/src/pages') diff --git a/panel/src/pages/Dashboard.jsx b/panel/src/pages/Dashboard.jsx index 5aa2b0c..d16204d 100644 --- a/panel/src/pages/Dashboard.jsx +++ b/panel/src/pages/Dashboard.jsx @@ -1,5 +1,9 @@ -import React from 'react'; +import React, { useEffect, useRef } from 'react'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend } from 'chart.js'; import { Bar } from 'react-chartjs-2'; +import Navbar from '../components/Navbar'; + +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend); const Dashboard = () => { const userStats = { totalUsers: 100, totalAds: 50, totalRevenue: 5000 }; @@ -15,16 +19,31 @@ const Dashboard = () => { ], }; + const chartRef = useRef(null); + + useEffect(() => { + const chartInstance = chartRef.current.chartInstance; + + return () => { + if (chartInstance) { + chartInstance.destroy(); + } + }; + }, []); + return ( -
-

Dashboard

-
-
Total Users: {userStats.totalUsers}
-
Total Ads: {userStats.totalAds}
-
Total Revenue: {userStats.totalRevenue}
-
-
- +
+ +
+

Dashboard

+
+
Total Users: {userStats.totalUsers}
+
Total Ads: {userStats.totalAds}
+
Total Revenue: {userStats.totalRevenue}
+
+
+ +
); diff --git a/panel/src/pages/ManageAds.jsx b/panel/src/pages/ManageAds.jsx index 4ec0b36..70142d2 100644 --- a/panel/src/pages/ManageAds.jsx +++ b/panel/src/pages/ManageAds.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { db } from '../firebase'; import { collection, addDoc, getDocs } from 'firebase/firestore'; +import Navbar from '../components/Navbar'; const ManageAds = () => { const [ads, setAds] = useState([]); @@ -22,46 +23,49 @@ const ManageAds = () => { }; return ( -
-

Manage Ads

-
-
- - setNewAd({ ...newAd, title: e.target.value })} - className="form-control" - /> -
-
- - setNewAd({ ...newAd, description: e.target.value })} - className="form-control" - /> +
+ +
+

Manage Ads

+
+
+ + setNewAd({ ...newAd, title: e.target.value })} + className="form-control" + /> +
+
+ + setNewAd({ ...newAd, description: e.target.value })} + className="form-control" + /> +
+
+ + setNewAd({ ...newAd, imageUrl: e.target.value })} + className="form-control" + /> +
+
-
- - setNewAd({ ...newAd, imageUrl: e.target.value })} - className="form-control" - /> +
+ {ads.map((ad, index) => ( +
+
{ad.title}
+

{ad.description}

+ {ad.title} +
+ ))}
- -
-
- {ads.map((ad, index) => ( -
-
{ad.title}
-

{ad.description}

- {ad.title} -
- ))}
); diff --git a/panel/src/pages/Roles.jsx b/panel/src/pages/Roles.jsx index 05f73b6..5b18ace 100644 --- a/panel/src/pages/Roles.jsx +++ b/panel/src/pages/Roles.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import { db, auth } from '../firebase'; import { collection, getDocs } from 'firebase/firestore'; import { httpsCallable } from 'firebase/functions'; +import Navbar from '../components/Navbar'; const Roles = () => { const [users, setUsers] = useState([]); @@ -33,16 +34,21 @@ const Roles = () => { } return ( -
-

Manage Roles

-
- {users.map((user, index) => ( -
-

{user.email}

- - -
- ))} +
+ +
+

Manage Roles

+
+ {users.map((user, index) => ( +
+

{user.email}

+
+ + +
+
+ ))} +
); -- cgit v1.2.3-59-g8ed1b