From 3b3db6f702336afe308eb6e36e18aad53585b9b4 Mon Sep 17 00:00:00 2001 From: YouSry3 Date: Fri, 22 Aug 2025 13:14:14 +0300 Subject: [PATCH 1/3] version '1' from visulization about Dashboard --- src/Pages/Dashboard.tsx | 59 ++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/Pages/Dashboard.tsx b/src/Pages/Dashboard.tsx index c0c82bf..e97849f 100644 --- a/src/Pages/Dashboard.tsx +++ b/src/Pages/Dashboard.tsx @@ -2,48 +2,65 @@ import { PieChart, Pie, Cell, Tooltip, Legend, ResponsiveContainer } from "recharts"; import { useAuth } from "../Auth/AuthContext"; import useTodos from "../Hooks/useTodos"; +import { Statuses } from "../Data"; +// ...existing code... +const Dashboard = () => { + // Get todos from your custom hook + const { user } = useAuth(); + const { todos } = useTodos(user?.jwt); -const data = [ - { name: "Completed Tasks", value: 65 }, - { name: "In Progress", value: 20 }, - { name: "Pending", value: 15 }, -]; -// + // Count completed and pending todos + const completedCount = todos?.data.filter(todo=> todo.todo_status === Statuses[2].name).length || 0; + const pendingCount = todos?.data.filter(todo=> todo.todo_status === Statuses[0].name).length || 0; -const COLORS = ["#4CAF50", "#FFC107", "#F44336"]; -const {user} = useAuth(); + // Prepare data for PieChart + const data = [ + { name: "Completed", value: completedCount }, + { name: "Pending", value: pendingCount }, + ]; -const {todos} = useTodos(user?.jwt); + const COLORS = ["#00C49F", "#FF8042"]; -const Dashboard = () => { return ( -
-

📊 Dashboard Overview

- -
-

Project Status

- + <> +

Todo Status Overview

+
+ ( + + {`${name}: ${(percent * 100).toFixed(0)}%`} + + )} outerRadius={100} - paddingAngle={5} + fill="#8884d8" dataKey="value" > - {data.map((entry, index) => ( + {data.map((_, index) => ( ))} - +
-
+ ); }; export default Dashboard; +// ...existing code... From 8f090d9949c35d1341f313e5ff4c87377f5cd06c Mon Sep 17 00:00:00 2001 From: YouSry3 Date: Fri, 22 Aug 2025 13:20:22 +0300 Subject: [PATCH 2/3] Fixed this Error --- src/Pages/Dashboard.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Pages/Dashboard.tsx b/src/Pages/Dashboard.tsx index e97849f..f58d4e0 100644 --- a/src/Pages/Dashboard.tsx +++ b/src/Pages/Dashboard.tsx @@ -11,6 +11,7 @@ const Dashboard = () => { // Count completed and pending todos const completedCount = todos?.data.filter(todo=> todo.todo_status === Statuses[2].name).length || 0; + // Count pending todos const pendingCount = todos?.data.filter(todo=> todo.todo_status === Statuses[0].name).length || 0; // Prepare data for PieChart From 4d3b2a7d65afeaec8bae2a0a179140a1bf0ab95e Mon Sep 17 00:00:00 2001 From: YouSry3 Date: Sat, 23 Aug 2025 11:18:13 +0300 Subject: [PATCH 3/3] v0.1 from Dashborad of project 'mangment tsaks' --- src/Pages/Dashboard.tsx | 95 ++++++++++++++++++++++++++++++----------- src/Pages/TodoLists.tsx | 2 +- 2 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/Pages/Dashboard.tsx b/src/Pages/Dashboard.tsx index f58d4e0..7ee0092 100644 --- a/src/Pages/Dashboard.tsx +++ b/src/Pages/Dashboard.tsx @@ -1,30 +1,49 @@ // Pages/Dashboard.tsx -import { PieChart, Pie, Cell, Tooltip, Legend, ResponsiveContainer } from "recharts"; +import { + PieChart, + Pie, + Cell, + Tooltip, + Legend, + ResponsiveContainer, +} from "recharts"; import { useAuth } from "../Auth/AuthContext"; import useTodos from "../Hooks/useTodos"; import { Statuses } from "../Data"; -// ...existing code... + const Dashboard = () => { - // Get todos from your custom hook const { user } = useAuth(); const { todos } = useTodos(user?.jwt); - // Count completed and pending todos - const completedCount = todos?.data.filter(todo=> todo.todo_status === Statuses[2].name).length || 0; - // Count pending todos - const pendingCount = todos?.data.filter(todo=> todo.todo_status === Statuses[0].name).length || 0; + // Counts + const completedCount = + todos?.data.filter((todo) => todo.todo_status === Statuses[2].name).length || + 0; + const pendingCount = + todos?.data.filter((todo) => todo.todo_status === Statuses[0].name).length || + 0; + const inProgressCount = + todos?.data.filter((todo) => todo.todo_status === Statuses[1].name).length || + 0; + + const totalCount = completedCount + pendingCount + inProgressCount; - // Prepare data for PieChart + // Pie chart data const data = [ { name: "Completed", value: completedCount }, { name: "Pending", value: pendingCount }, + { name: "In Progress", value: inProgressCount }, ]; - const COLORS = ["#00C49F", "#FF8042"]; + const COLORS = ["#00C49F", "#FF8042", "#0088FE"]; return ( <> -

Todo Status Overview

+

+ Todo Status Overview +

+ + {/* Chart */}
@@ -33,25 +52,17 @@ const Dashboard = () => { cx="50%" cy="50%" labelLine={false} - label={({ name, percent = 0, x, y }) => ( - - {`${name}: ${(percent * 100).toFixed(0)}%`} - - )} + label={({ name, percent = 0 }) => + `${name}: ${(percent * 100).toFixed(0)}%` + } outerRadius={100} - fill="#8884d8" dataKey="value" > {data.map((_, index) => ( - + ))} @@ -59,9 +70,41 @@ const Dashboard = () => {
+ + {/* Stats cards */} +
+
+

Completed

+

+ {completedCount} +

+ + {(totalCount ? (completedCount / totalCount) * 100 : 0).toFixed(0)}% + +
+ +
+

In Progress

+

+ {inProgressCount} +

+ + {(totalCount ? (inProgressCount / totalCount) * 100 : 0).toFixed(0)}% + +
+ +
+

Pending

+

+ {pendingCount} +

+ + {(totalCount ? (pendingCount / totalCount) * 100 : 0).toFixed(0)}% + +
+
); }; export default Dashboard; -// ...existing code... diff --git a/src/Pages/TodoLists.tsx b/src/Pages/TodoLists.tsx index 09d8e7a..4dc6385 100644 --- a/src/Pages/TodoLists.tsx +++ b/src/Pages/TodoLists.tsx @@ -25,7 +25,7 @@ const TodoLists = ({ return ( -
+
{todos.data.map((todo) => { const matchedStatus = Statuses.find(s => s.name === todo.todo_status);