Skip to content

Commit

Permalink
feat: added admin dashboard charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Just-a-Pirate committed Apr 26, 2024
1 parent de76418 commit 44e0264
Show file tree
Hide file tree
Showing 3 changed files with 516 additions and 0 deletions.
53 changes: 53 additions & 0 deletions frontend/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import { HttpCodes } from "@/types/HttpCodes";
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, useDisclosure } from "@nextui-org/modal";
import { set } from "react-hook-form";
import { Input } from "@nextui-org/input";
import { DonutChart } from "@tremor/react";


axios.defaults.withCredentials = true;


const AdminHomepage = () => {
const [amLoggedIn, setAmLoggedIn] = useState<boolean>(false);

Expand Down Expand Up @@ -284,7 +286,58 @@ const AdminHomepage = () => {
</CardBody>
</Card>
</div>
<div className="md:flex">
<Card className="dark:bg-slate-700 md:mx-2 my-2 xl:max-w-sm rounded-xl w-full p-3">
<DonutChart
data={
[{
Status: "Pending ",
Posts: posts.filter(post => post.status == "open").length
},
{
Status: "Closed ",
Posts: posts.filter(post => post.status == "closed").length
},
{
Status: "Completed ",
Posts: posts.filter(post => post.status == "completed").length
}]
}
index="Status"
category="Posts"
variant="donut"
colors={[
'white', 'black', '#6b7280']}
/>
</Card>
<Card className="bg-white md:mx-2 my-2 xl:max-w-sm rounded-xl w-full p-3">
<DonutChart
data={
[{
Role: "Default",
Users: users.filter(user => user.role == "user").length
},
{
Role: "Admin",
Users: users.filter(user => user.role == "admin").length
},
{
Role: "Banned",
Users: users.filter(user => user.role == "banned").length
}]
}
index="Role"
category="Users"
variant="donut"
colors={[
'white',
'slate',
'red'
]}
/>
</Card>

</div>
{/* User Summary */}
{message && <p className="text-center text-xl m-2">{message}</p>}
{error && <p className="text-red-600 text-center text-xl m-2">{error}</p>}
Expand Down
Loading

0 comments on commit 44e0264

Please sign in to comment.