mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 22:14:07 +01:00
Merge branch 'main' into feature/tasks-api
This commit is contained in:
commit
72934d9175
@ -54,6 +54,7 @@ export default function SignUp() {
|
|||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
setFormData({ ...formData, [name]: value });
|
setFormData({ ...formData, [name]: value });
|
||||||
|
console.log(formData);
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
/* Particles Loader*/
|
/* Particles Loader*/
|
||||||
@ -218,7 +219,7 @@ export default function SignUp() {
|
|||||||
</div>
|
</div>
|
||||||
<br></br>
|
<br></br>
|
||||||
|
|
||||||
{/* Login Button */}
|
{/* Signups Button */}
|
||||||
<button className="btn btn-success w-full " onClick={handleSubmit}>
|
<button className="btn btn-success w-full " onClick={handleSubmit}>
|
||||||
Signup
|
Signup
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
65
frontend/src/components/dashboard/Areachart.jsx
Normal file
65
frontend/src/components/dashboard/Areachart.jsx
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { AreaChart, Title } from "@tremor/react";
|
||||||
|
import React from "react";
|
||||||
|
import axiosInstance from "../../api/configs/AxiosConfig";
|
||||||
|
|
||||||
|
const fetchAreaChartData = async () => {
|
||||||
|
let res = await axiosInstance.get("/dashboard/weekly/");
|
||||||
|
console.log(res.data);
|
||||||
|
const areaChartData = [
|
||||||
|
{
|
||||||
|
date: "Monday",
|
||||||
|
"This Week": res.data[0]["This Week"],
|
||||||
|
"Last Week": res.data[0]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Tuesday",
|
||||||
|
"This Week": res.data[1]["This Week"],
|
||||||
|
"Last Week": res.data[1]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Wednesday",
|
||||||
|
"This Week": res.data[2]["This Week"],
|
||||||
|
"Last Week": res.data[2]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Thursday",
|
||||||
|
"This Week": res.data[3]["This Week"],
|
||||||
|
"Last Week": res.data[3]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Friday",
|
||||||
|
"This Week": res.data[4]["This Week"],
|
||||||
|
"Last Week": res.data[4]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Saturday",
|
||||||
|
"This Week": res.data[5]["This Week"],
|
||||||
|
"Last Week": res.data[5]["Last Week"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "Sunday",
|
||||||
|
"This Week": res.data[6]["This Week"],
|
||||||
|
"Last Week": res.data[6]["Last Week"],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const areaChartDataArray = await fetchAreaChartData();
|
||||||
|
export const AreaChartGraph = () => {
|
||||||
|
const [value, setValue] = React.useState(null);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Title>Number of tasks statistics vs. last week</Title>
|
||||||
|
<AreaChart
|
||||||
|
className="mt-6"
|
||||||
|
data={areaChartDataArray}
|
||||||
|
index="date"
|
||||||
|
categories={["This Week", "Last Week"]}
|
||||||
|
colors={["neutral", "indigo"]}
|
||||||
|
yAxisWidth={30}
|
||||||
|
onValueChange={(v) => setValue(v)}
|
||||||
|
showAnimation
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -1,93 +1,66 @@
|
|||||||
import { BarChart, Card, Title } from "@tremor/react";
|
import { BarChart, Title } from "@tremor/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import axiosInstance from "../../api/configs/AxiosConfig";
|
import axiosInstance from "../../api/configs/AxiosConfig";
|
||||||
|
|
||||||
const apiGetBarChartData = () => {
|
const fetchBarChartData = async () => {
|
||||||
return axiosInstance.get("dashboard/stats/");
|
let res = await axiosInstance.get("/dashboard/weekly/");
|
||||||
}
|
console.log(res.data);
|
||||||
console.log(apiGetBarChartData);
|
const barchartData = [
|
||||||
|
{
|
||||||
const chartdata3 = [
|
date: "Monday",
|
||||||
{
|
"This Week": res.data[0]["Completed This Week"],
|
||||||
date: "Jan 23",
|
"Last Week": res.data[0]["Completed Last Week"],
|
||||||
"2022": 45,
|
},
|
||||||
"2023": 78,
|
{
|
||||||
},
|
date: "Tuesday",
|
||||||
{
|
"This Week": res.data[1]["Completed This Week"],
|
||||||
date: "Feb 23",
|
"Last Week": res.data[1]["Completed Last Week"],
|
||||||
"2022": 52,
|
},
|
||||||
"2023": 71,
|
{
|
||||||
},
|
date: "Wednesday",
|
||||||
{
|
"This Week": res.data[2]["Completed This Week"],
|
||||||
date: "Mar 23",
|
"Last Week": res.data[2]["Completed Last Week"],
|
||||||
"2022": 48,
|
},
|
||||||
"2023": 80,
|
{
|
||||||
},
|
date: "Thursday",
|
||||||
{
|
"This Week": res.data[3]["Completed This Week"],
|
||||||
date: "Apr 23",
|
"Last Week": res.data[3]["Completed Last Week"],
|
||||||
"2022": 61,
|
},
|
||||||
"2023": 65,
|
{
|
||||||
},
|
date: "Friday",
|
||||||
{
|
"This Week": res.data[4]["Completed This Week"],
|
||||||
date: "May 23",
|
"Last Week": res.data[4]["Completed Last Week"],
|
||||||
"2022": 55,
|
},
|
||||||
"2023": 58,
|
{
|
||||||
},
|
date: "Saturday",
|
||||||
{
|
"This Week": res.data[5]["Completed This Week"],
|
||||||
date: "Jun 23",
|
"Last Week": res.data[5]["Completed Last Week"],
|
||||||
"2022": 67,
|
},
|
||||||
"2023": 62,
|
{
|
||||||
},
|
date: "Sunday",
|
||||||
{
|
"This Week": res.data[6]["Completed This Week"],
|
||||||
date: "Jul 23",
|
"Last Week": res.data[6]["Completed Last Week"],
|
||||||
"2022": 60,
|
},
|
||||||
"2023": 54,
|
];
|
||||||
},
|
return barchartData;
|
||||||
{
|
|
||||||
date: "Aug 23",
|
};
|
||||||
"2022": 72,
|
const barchartDataArray = await fetchBarChartData();
|
||||||
"2023": 49,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "Sep 23",
|
|
||||||
"2022": 65,
|
|
||||||
"2023": 52,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "Oct 23",
|
|
||||||
"2022": 68,
|
|
||||||
"2023": null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "Nov 23",
|
|
||||||
"2022": 74,
|
|
||||||
"2023": null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "Dec 23",
|
|
||||||
"2022": 71,
|
|
||||||
"2023": null,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const BarChartGraph = () => {
|
export const BarChartGraph = () => {
|
||||||
const [value, setValue] = React.useState(null);
|
const [value, setValue] = React.useState(null);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card>
|
<Title>Task completed statistics vs. last week</Title>
|
||||||
<Title>Closed Pull Requests</Title>
|
|
||||||
<BarChart
|
<BarChart
|
||||||
className="mt-6"
|
className="mt-6"
|
||||||
data={chartdata3}
|
data={barchartDataArray}
|
||||||
index="date"
|
index="date"
|
||||||
categories={["2022", "2023"]}
|
categories={["This Week", "Last Week"]}
|
||||||
colors={["neutral", "indigo"]}
|
colors={["neutral", "indigo"]}
|
||||||
yAxisWidth={30}
|
yAxisWidth={30}
|
||||||
onValueChange={(v) => setValue(v)}
|
onValueChange={(v) => setValue(v)}
|
||||||
showAnimation
|
showAnimation
|
||||||
/>
|
/>
|
||||||
</Card>
|
|
||||||
<pre>{JSON.stringify(value)}</pre>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
39
frontend/src/components/dashboard/DonutChart.jsx
Normal file
39
frontend/src/components/dashboard/DonutChart.jsx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { DonutChart } from "@tremor/react";
|
||||||
|
import axiosInstance from "../../api/configs/AxiosConfig";
|
||||||
|
|
||||||
|
const fetchDonutData = async () => {
|
||||||
|
try {
|
||||||
|
let res = await axiosInstance.get("/dashboard/stats/");
|
||||||
|
let todoCount = res.data.todo_count;
|
||||||
|
let recurrenceCount = res.data.recurrence_count;
|
||||||
|
if (todoCount === undefined) {
|
||||||
|
todoCount = 0;
|
||||||
|
}
|
||||||
|
if (recurrenceCount === undefined) {
|
||||||
|
recurrenceCount = 0;
|
||||||
|
}
|
||||||
|
const donutData = [
|
||||||
|
{ name: "Todo", count: todoCount },
|
||||||
|
{ name: "Recurrence", count: recurrenceCount },
|
||||||
|
];
|
||||||
|
return donutData;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching donut data:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const donutDataArray = await fetchDonutData();
|
||||||
|
export default function DonutChartGraph() {
|
||||||
|
return (
|
||||||
|
<DonutChart
|
||||||
|
className="mt-6"
|
||||||
|
data={donutDataArray}
|
||||||
|
category="count"
|
||||||
|
index="name"
|
||||||
|
colors={["rose", "yellow", "orange"]}
|
||||||
|
onValueChange={(v) => setValue(v)}
|
||||||
|
showAnimation
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,21 +1,40 @@
|
|||||||
|
|
||||||
import { BadgeDelta, Card, Flex, Metric, ProgressBar, Text } from "@tremor/react";
|
import { BadgeDelta, Card, Flex, Metric, ProgressBar, Text } from "@tremor/react";
|
||||||
|
import React from "react";
|
||||||
|
import axiosInstance from "../../api/configs/AxiosConfig";
|
||||||
|
|
||||||
|
const fetchKpiCardData = async () => {
|
||||||
|
let res = await axiosInstance.get("/dashboard/stats/");
|
||||||
|
let completedThisWeek = res.data["completed_this_week"];
|
||||||
|
let completedLastWeek = res.data["completed_last_week"];
|
||||||
|
let percentage = (completedThisWeek / completedLastWeek)*100;
|
||||||
|
let incOrdec = undefined;
|
||||||
|
if (completedThisWeek <= completedLastWeek) {
|
||||||
|
incOrdec = "moderateDecrease";
|
||||||
|
}
|
||||||
|
if (completedThisWeek > completedLastWeek) {
|
||||||
|
incOrdec = "moderateIncrease";
|
||||||
|
}
|
||||||
|
return {completedThisWeek, completedLastWeek, incOrdec, percentage};
|
||||||
|
}
|
||||||
|
|
||||||
|
const {kpiCardDataArray, completedThisWeek ,completedLastWeek, incOrdec, percentage} = await fetchKpiCardData();
|
||||||
|
|
||||||
|
|
||||||
export default function KpiCard() {
|
export default function KpiCard() {
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<Card className="max-w-lg mx-auto">
|
<Card className="max-w-lg mx-auto">
|
||||||
<Flex alignItems="start">
|
<Flex alignItems="start">
|
||||||
<div>
|
<div>
|
||||||
<Text>Sales</Text>
|
<Metric>{completedThisWeek}</Metric>
|
||||||
<Metric>$ 12,699</Metric>
|
|
||||||
</div>
|
</div>
|
||||||
<BadgeDelta deltaType="moderateIncrease">13.2%</BadgeDelta>
|
<BadgeDelta deltaType={incOrdec}>{percentage}%</BadgeDelta>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex className="mt-4">
|
<Flex className="mt-4">
|
||||||
<Text className="truncate">68% ($ 149,940)</Text>
|
<Text className="truncate">vs. {completedLastWeek} (last week)</Text>
|
||||||
<Text>$ 220,500</Text>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
<ProgressBar value={15.9} className="mt-2" />
|
<ProgressBar value={percentage} className="mt-2" />
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1,20 +1,24 @@
|
|||||||
import { Card, Grid, Tab, TabGroup, TabList, TabPanel, TabPanels, Text, Title, DonutChart } from "@tremor/react";
|
import {
|
||||||
|
Card,
|
||||||
|
Grid,
|
||||||
|
Tab,
|
||||||
|
TabGroup,
|
||||||
|
TabList,
|
||||||
|
TabPanel,
|
||||||
|
TabPanels,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
DonutChart,
|
||||||
|
Legend,
|
||||||
|
} from "@tremor/react";
|
||||||
import KpiCard from "./kpiCard";
|
import KpiCard from "./kpiCard";
|
||||||
import { BarChartGraph } from "./Barchart";
|
import { BarChartGraph } from "./Barchart";
|
||||||
|
import DonutChartGraph from "./DonutChart";
|
||||||
|
import { AreaChartGraph } from "./Areachart";
|
||||||
|
|
||||||
const cities = [
|
|
||||||
{
|
|
||||||
name: "New York",
|
|
||||||
sales: 9800,
|
|
||||||
},
|
|
||||||
// ...
|
|
||||||
{
|
|
||||||
name: "Zurich",
|
|
||||||
sales: 1398,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const valueFormatter = number => `$ ${new Intl.NumberFormat("us").format(number).toString()}`;
|
const valueFormatter = (number) =>
|
||||||
|
`$ ${new Intl.NumberFormat("us").format(number).toString()}`;
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
return (
|
return (
|
||||||
@ -34,26 +38,30 @@ export default function Dashboard() {
|
|||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Grid numItemsMd={2} numItemsLg={3} className="gap-6 mt-6">
|
<Grid numItemsMd={2} numItemsLg={3} className="gap-6 mt-6">
|
||||||
<Card>
|
<Card>
|
||||||
<KpiCard />
|
<Title>Highlights vs. last week</Title>
|
||||||
<br />
|
<br />
|
||||||
<KpiCard />
|
<KpiCard />
|
||||||
|
<br />
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<BarChartGraph />
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<AreaChartGraph />
|
||||||
</Card>
|
</Card>
|
||||||
{/* Placeholder to set height */}
|
|
||||||
<div className="h-31">
|
<div className="h-31">
|
||||||
<Card className="mx-auto h-full">
|
<Card className="mx-auto h-full">
|
||||||
<Title>Sales</Title>
|
<Title>Tasks</Title>
|
||||||
<DonutChart
|
<DonutChartGraph />
|
||||||
className="mt-6"
|
<br/>
|
||||||
data={cities}
|
<Legend
|
||||||
category="sales"
|
className="mt-3 mx-auto w-1/2"
|
||||||
index="name"
|
categories={["Todo Task", "Recurrence Task"]}
|
||||||
colors={["rose", "yellow", "orange", "indigo", "blue", "emerald"]}
|
colors={["rose", "yellow"]}
|
||||||
onValueChange={v => setValue(v)}
|
|
||||||
showAnimation
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<BarChartGraph />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user