diff --git a/src/components/Charts/Circle.jsx b/src/components/Charts/Circle.jsx index 6b0669bf..da260cdb 100644 --- a/src/components/Charts/Circle.jsx +++ b/src/components/Charts/Circle.jsx @@ -2,79 +2,79 @@ import React from "react"; import ReactApexChart from "react-apexcharts"; const ApexChart = ({ completed = 0, planned = 1 }) => { -const percentage = planned > 0 ? Math.round((completed / planned) * 100) : 0; + const percentage = planned > 0 ? Math.round((completed / planned) * 100) : 0; -const options = { -chart: { -height: 200, -type: "radialBar", -toolbar: { show: false }, -}, -plotOptions: { -radialBar: { -startAngle: -135, -endAngle: 225, -hollow: { -margin: 0, -size: "60%", -background: "#fff", -dropShadow: { -enabled: true, -top: 2, -left: 0, -blur: 3, -opacity: 0.45, -}, -}, -track: { -background: "#f5f5f5", -strokeWidth: "67%", -dropShadow: { enabled: false }, -}, -dataLabels: { -show: true, -name: { -offsetY: -10, -color: "#888", -fontSize: "14px", -}, -value: { -formatter: (val) => `${val}%`, -color: "#111", -fontSize: "24px", -show: true, -}, -}, -}, -}, -fill: { -type: "gradient", -gradient: { -shade: "dark", -type: "horizontal", -shadeIntensity: 0.5, -gradientToColors: ["#ABE5A1"], -opacityFrom: 1, -opacityTo: 1, -stops: [0, 100], -}, -}, -stroke: { -lineCap: "round", -}, -labels: ["Progress"], -}; + const options = { + chart: { + height: 200, + type: "radialBar", + toolbar: { show: false }, + }, + plotOptions: { + radialBar: { + startAngle: -135, + endAngle: 225, + hollow: { + margin: 0, + size: "60%", + background: "#fff", + dropShadow: { + enabled: true, + top: 2, + left: 0, + blur: 3, + opacity: 0.45, + }, + }, + track: { + background: "#f5f5f5", + strokeWidth: "40%", + dropShadow: { enabled: false }, + }, + dataLabels: { + show: true, + name: { + offsetY: -10, + color: "#888", + fontSize: "14px", + }, + value: { + formatter: (val) => `${val}%`, + color: "#111", + fontSize: "24px", + show: true, + }, + }, + }, + }, + fill: { + type: "gradient", + gradient: { + shade: "dark", + type: "horizontal", + shadeIntensity: 0.5, + gradientToColors: ["#ABE5A1"], + opacityFrom: 1, + opacityTo: 1, + stops: [0, 100], + }, + }, + stroke: { + lineCap: "round", + }, + labels: ["Progress"], + }; -return ( -
Activity Progress Chart
+Daily Activity Data
Loading activity data...
) : isError ? ( @@ -135,13 +152,17 @@ const Activity = () => { Completed / AssignedActivity / Location | -Assigned / Completed | +Location / Activity | +Assigned / Completed |
---|---|---|---|
{log.activity} | -{log.assignedToday} / {log.completed} | + {ActivityData?.performedActivites && ActivityData.performedActivites.length > 0 ? ( + ActivityData.performedActivites.map((activity, index) => ( +||
+ {activity.buldingName}, {activity.floorName}, {activity.workAreaName} + + {activity.activityName} + + + + |
+
+ {activity.assignedToday} / {activity.completedToday} | {/* <-- Right aligned */} +||
No activity data available |
Name | -Checkin | -Checkout | +Name | +Checkin | +Checkout | +
---|---|---|---|---|---|
@@ -191,7 +199,7 @@ const Attendance = () => { minute: "2-digit", })} | -+ |
{new Date(record.outTime).toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
diff --git a/src/components/Dashboard/Dashboard.jsx b/src/components/Dashboard/Dashboard.jsx
index b2c6b904..6d0ea072 100644
--- a/src/components/Dashboard/Dashboard.jsx
+++ b/src/components/Dashboard/Dashboard.jsx
@@ -3,37 +3,46 @@ import {
useDashboardProjectsCardData,
useDashboardTeamsCardData,
useDashboardTasksCardData,
+ useDashboardPendingAttendenceData,
} from "../../hooks/useDashboard_Data";
import Projects from "./Projects";
import Teams from "./Teams";
import TasksCard from "./Tasks";
import ProjectCompletionChart from "./ProjectCompletionChart";
import ProjectProgressChart from "./ProjectProgressChart";
-// import Attendance from "./Attendance";
+import Attendance from "./Attendance";
+import PendingAttendance from "./PendingAttendance";
+import Activity from "./Activity";
const Dashboard = () => {
const { projectsCardData } = useDashboardProjectsCardData();
const { teamsCardData } = useDashboardTeamsCardData();
const { tasksCardData } = useDashboardTasksCardData();
+ const { PendingAttendenceData} = useDashboardPendingAttendenceData();
return (
{/* Projects Card */}
-
+
+
);
diff --git a/src/hooks/useDashboard_Data.jsx b/src/hooks/useDashboard_Data.jsx
index a46aa0c8..2f43fa61 100644
--- a/src/hooks/useDashboard_Data.jsx
+++ b/src/hooks/useDashboard_Data.jsx
@@ -1,5 +1,6 @@
import { useState, useEffect } from "react";
import GlobalRepository from "../repositories/GlobalRepository";
+import Attendance from "../components/Dashboard/Attendance";
// 🔹 Dashboard Progression Data Hook
export const useDashboard_Data = ({ days, FromDate, projectId }) => {
@@ -67,6 +68,38 @@ export const useDashboard_AttendanceData = (date, projectId) => {
return { dashboard_Attendancedata, isLineChartLoading: isLineChartLoading, error };
};
+// Activity weidget
+
+export const useDashboard_ActivityData = (date, projectId) => {
+ const [dashboard_Activitydata, setDashboard_ActivityData] = useState([]);
+ const [isLineChartLoading, setLoading] = useState(false);
+ const [error, setError] = useState("");
+
+ useEffect(() => {
+ const fetchData = async () => {
+ setLoading(true);
+ setError("");
+
+ try {
+ const response = await GlobalRepository.getDashboardActivityData(date,projectId); // date in 2nd param
+ setDashboard_ActivityData(response.data);
+ } catch (err) {
+ setError("Failed to fetch dashboard data.");
+ console.error(err);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ if (date && projectId !== null) {
+ fetchData();
+ }
+ }, [date, projectId]);
+
+ return { dashboard_Activitydata, isLineChartLoading: isLineChartLoading, error };
+};
+
+
// 🔹 Dashboard Projects Card Data Hook
export const useDashboardProjectsCardData = () => {
@@ -151,3 +184,31 @@ export const useDashboardTasksCardData = () => {
return { tasksCardData, loading, error };
};
+
+// Pending Attendance
+export const useDashboardPendingAttendenceData = () => {
+ const [PendingAttendenceData, setPendingAttendence] = useState([]);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState("");
+
+ useEffect(() => {
+ const fetchPendingAttendence = async () => {
+ setLoading(true);
+ setError("");
+
+ try {
+ const response = await GlobalRepository.getDashboardPendingAttendence();
+ setPendingAttendence(response.data);
+ } catch (err) {
+ setError("Failed to fetch Pending Attendence card data.");
+ console.error(err);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchPendingAttendence();
+ }, []);
+
+ return { PendingAttendenceData, loading, error };
+};
diff --git a/src/repositories/GlobalRepository.jsx b/src/repositories/GlobalRepository.jsx
index eda5312e..dfb09386 100644
--- a/src/repositories/GlobalRepository.jsx
+++ b/src/repositories/GlobalRepository.jsx
@@ -3,12 +3,12 @@ import { api } from "../utils/axiosClient";
const GlobalRepository = {
getDashboardProgressionData: ({ days = '', FromDate = '', projectId = '' }) => {
let params;
- if(projectId == null){
+ if (projectId == null) {
params = new URLSearchParams({
days: days.toString(),
FromDate,
});
- }else{
+ } else {
params = new URLSearchParams({
days: days.toString(),
FromDate,
@@ -19,10 +19,10 @@ const GlobalRepository = {
return api.get(`/api/Dashboard/Progression?${params.toString()}`);
},
- getDashboardAttendanceData: ( date,projectId ) => {
+ getDashboardAttendanceData: (date, projectId) => {
- return api.get(`/api/Dashboard/project-attendance/${projectId}?date=${date}`);
-},
+ return api.get(`/api/Dashboard/project-attendance/${projectId}?date=${date}`);
+ },
getDashboardProjectsCardData: () => {
return api.get(`/api/Dashboard/projects`);
},
@@ -32,6 +32,12 @@ const GlobalRepository = {
getDashboardTasksCardData: () => {
return api.get(`/api/Dashboard/tasks`);
},
+ getDashboardPendingAttendence: () => {
+ return api.get(`/api/dashboard/pending-attendance`);
+ },
+ getDashboardActivityData: ( date,projectId ) => {
+ return api.get(`/api/Dashboard/activities/${projectId}?date=${date}`);
+},
};
+
+
+
{/* Bar Chart (Project Completion) */}
+
+
+
+
|