mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 05:54:07 +01:00
Refactor dashboard component imports and remove
unused code
This commit is contained in:
parent
1ab46f8668
commit
ea6353a455
43
frontend/src/components/dashboard/PieChart.jsx
Normal file
43
frontend/src/components/dashboard/PieChart.jsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { DonutChart } from "@tremor/react";
|
||||||
|
import axiosInstance from "../../api/configs/AxiosConfig";
|
||||||
|
|
||||||
|
const fetchPieData = async () => {
|
||||||
|
try {
|
||||||
|
let res = await axiosInstance.get("/dashboard/stats/");
|
||||||
|
// let todoCount = res.data.todo_count;
|
||||||
|
// let recurrenceCount = res.data.recurrence_count;
|
||||||
|
let todoCount = 10;
|
||||||
|
let recurrenceCount = 15;
|
||||||
|
if (todoCount === undefined) {
|
||||||
|
todoCount = 0;
|
||||||
|
}
|
||||||
|
if (recurrenceCount === undefined) {
|
||||||
|
recurrenceCount = 0;
|
||||||
|
}
|
||||||
|
const donutData = [
|
||||||
|
{ name: "Completed Tasks", count: todoCount },
|
||||||
|
{ name: "Uncompleted Tasks", count: recurrenceCount },
|
||||||
|
];
|
||||||
|
return donutData;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching donut data:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const pieDataArray = await fetchPieData();
|
||||||
|
|
||||||
|
export function PieChartGraph() {
|
||||||
|
return (
|
||||||
|
<DonutChart
|
||||||
|
className="mt-6"
|
||||||
|
data={pieDataArray}
|
||||||
|
category="count"
|
||||||
|
index="name"
|
||||||
|
colors={["rose", "yellow"]}
|
||||||
|
showAnimation
|
||||||
|
radius={25}
|
||||||
|
variant="pie"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,22 +1,29 @@
|
|||||||
import { Card, Grid, Tab, TabGroup, TabList, TabPanel, TabPanels, Text, Title, Legend } from "@tremor/react";
|
import {
|
||||||
import { KpiCard } from "./KpiCard";
|
Card,
|
||||||
|
Grid,
|
||||||
|
Tab,
|
||||||
|
TabGroup,
|
||||||
|
TabList,
|
||||||
|
TabPanel,
|
||||||
|
TabPanels,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
Legend,
|
||||||
|
} from "@tremor/react";
|
||||||
|
import {KpiCard} from "./KpiCard";
|
||||||
import { BarChartGraph } from "./Barchart";
|
import { BarChartGraph } from "./Barchart";
|
||||||
import { DonutChartGraph } from "./DonutChart";
|
|
||||||
import { AreaChartGraph } from "./Areachart";
|
import { AreaChartGraph } from "./Areachart";
|
||||||
import { ProgressCircleChart } from "./ProgressCircle";
|
import {ProgressCircleChart} from "./ProgressCircle";
|
||||||
import { useState } from "react";
|
|
||||||
|
const valueFormatter = (number) =>
|
||||||
|
`$ ${new Intl.NumberFormat("us").format(number).toString()}`;
|
||||||
|
|
||||||
export function Dashboard() {
|
export function Dashboard() {
|
||||||
const [value, setValue] = useState({
|
|
||||||
from: new Date(2021, 0, 1),
|
|
||||||
to: new Date(2023, 0, 7),
|
|
||||||
});
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col p-12">
|
<div className="flex flex-col p-12">
|
||||||
<div>
|
<div>
|
||||||
<Title>Dashboard</Title>
|
<Title>Dashboard</Title>
|
||||||
<Text>All of your progress will be shown right here.</Text>
|
<Text>All of your progress will be shown right here.</Text>
|
||||||
<br />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@ -40,7 +47,8 @@ export function Dashboard() {
|
|||||||
<Legend
|
<Legend
|
||||||
className="mt-3 mx-auto w-1/2"
|
className="mt-3 mx-auto w-1/2"
|
||||||
categories={["Completed Tasks", "Assigned Tasks"]}
|
categories={["Completed Tasks", "Assigned Tasks"]}
|
||||||
colors={["indigo"]}></Legend>
|
colors={["indigo"]}
|
||||||
|
></Legend>
|
||||||
</Card>
|
</Card>
|
||||||
<Card>
|
<Card>
|
||||||
<BarChartGraph />
|
<BarChartGraph />
|
||||||
@ -51,18 +59,17 @@ export function Dashboard() {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<div className="h-31">
|
<div className="h-31">
|
||||||
<Card className="mx-auto h-full">
|
<Card className="mx-auto h-full">
|
||||||
<Title>Tasks</Title>
|
<Title>Tasks</Title>
|
||||||
<DonutChartGraph />
|
<br />
|
||||||
<br />
|
<Legend
|
||||||
<Legend
|
className="mt-3 mx-auto w-1/2"
|
||||||
className="mt-3 mx-auto w-1/2"
|
categories={["Todo Task", "Recurrence Task"]}
|
||||||
categories={["Todo Task", "Recurrence Task"]}
|
colors={["rose", "yellow"]}
|
||||||
colors={["rose", "yellow"]}
|
/>
|
||||||
/>
|
</Card>
|
||||||
</Card>
|
</div>
|
||||||
</div>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
</TabGroup>
|
</TabGroup>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user