-
+
+
-
Average Progress
-
{stats.averageProgress}%
-
-
-
-
- {/* 5. On-Time Projects */}
-
-
-
-
-
-
-
On-Time Projects
-
{stats.onTimeRatio}
-
-
-
-
- {/* 6. At Risk / Delayed */}
-
-
-
-
-
At Risk / Delayed
-
{stats.atRiskDelayed}
+
+ Needs Attention
+
+
{stats.needsAttention}
diff --git a/app/(dashboard)/task/utils/assignment-overview-helpers.ts b/app/(dashboard)/task/utils/assignment-overview-helpers.ts
index eb5551a..f354d7d 100644
--- a/app/(dashboard)/task/utils/assignment-overview-helpers.ts
+++ b/app/(dashboard)/task/utils/assignment-overview-helpers.ts
@@ -157,6 +157,14 @@ export interface AssignmentOverview {
nextMilestoneText: string;
updatedAgoText: string;
latestActivityText: string;
+
+ // Warning status & reasons (Health Critical/Off Track or Actual Progress < Days Elapsed)
+ hasWarning: boolean;
+ warningTitle: string;
+ warningReason: string;
+ warningDetails: string[];
+ isCriticalOrOffTrack: boolean;
+ isBehindSchedule: boolean;
}
export function formatAssignmentDate(dateStr?: string) {
@@ -705,7 +713,7 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num
// 2. Resolve Technical Status & Delivery Health
const { hasTechnicalStatus, technicalRank } = resolveTechnicalStatus(assignment);
const ptrEndDate = getPtrEndDate(assignment);
- const { healthStatus, healthBadgeClass, healthDotClass, isCritical } = resolveDeliveryHealth(
+ const { healthStatus, healthBadgeClass, healthDotClass } = resolveDeliveryHealth(
technicalRank,
hasTechnicalStatus,
progressPercent,
@@ -761,12 +769,41 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num
const updatedAgoText = formatRelativeTime(assignment.created_at || startDate);
- const actualProgress = typeof assignment.progress === 'number' && !isNaN(assignment.progress)
- ? Math.min(100, Math.max(0, assignment.progress))
- : 0;
+ const actualProgress = typeof assignment.progress === 'number' && !isNaN(assignment.progress) ? Math.min(100, Math.max(0, assignment.progress)) : 0;
const latestActivityText = formatLatestActivityWording(assignment.project_assignment_history);
+ // 5. Warning condition: healthStatus is 'Critical' or 'Off Track' OR actualProgress < progressPercent (days elapsed)
+ const isCriticalOrOffTrack = healthStatus === 'Critical' || healthStatus === 'Off Track';
+ const isBehindSchedule = healthStatus !== 'Completed' && actualProgress < progressPercent;
+ const hasWarning = isCriticalOrOffTrack || isBehindSchedule;
+
+ let warningTitle = '';
+ let warningReason = '';
+ const warningDetails: string[] = [];
+
+ if (isCriticalOrOffTrack && isBehindSchedule) {
+ warningTitle = `Attention Needed: ${healthStatus} & Behind Schedule`;
+ warningReason = `Project deadline has passed and actual progress (${actualProgress}%) is lagging behind timeline elapsed (${progressPercent}%).`;
+ warningDetails.push(`Status: ${healthStatus} (${remainingText || 'Passed deadline'})`);
+ warningDetails.push(`Actual: ${actualProgress}% vs Elapsed: ${progressPercent}% (${daysRatioText})`);
+ } else if (isCriticalOrOffTrack) {
+ warningTitle = `Attention Needed: ${healthStatus}`;
+ warningReason = `Project deadline has passed without reaching completion status (${remainingText || 'Passed deadline'}).`;
+ warningDetails.push(`Status: ${healthStatus}`);
+ if (endDate) {
+ warningDetails.push(`Deadline: ${formatAssignmentDate(endDate)}`);
+ }
+ } else if (isBehindSchedule) {
+ warningTitle = 'Attention Needed: Behind Schedule';
+ warningReason = `Actual progress (${actualProgress}%) is lagging behind the timeline elapsed (${progressPercent}%).`;
+ warningDetails.push(`Actual Progress: ${actualProgress}%`);
+ warningDetails.push(`Timeline Elapsed: ${progressPercent}% (${daysRatioText})`);
+ if (totalDays > elapsedDays) {
+ warningDetails.push(`${totalDays - elapsedDays} days remaining`);
+ }
+ }
+
return {
assignmentType,
isProject,
@@ -796,6 +833,12 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num
nextMilestoneText,
updatedAgoText,
latestActivityText,
+ hasWarning,
+ warningTitle,
+ warningReason,
+ warningDetails,
+ isCriticalOrOffTrack,
+ isBehindSchedule,
};
}
@@ -825,10 +868,11 @@ export function calculateDashboardStats(assignments: IProjectAssignment[]) {
});
const assignedPeopleCount = uniqueUsers.size;
- // Average progress
- const avgProgress = overviews.length > 0
- ? Math.round(overviews.reduce((acc, o) => acc + o.progressPercent, 0) / overviews.length)
- : 0;
+ // Warning / Needs Attention count: healthStatus is 'Critical' or 'Off Track' OR actualProgress < progressPercent (days elapsed)
+ const needsAttentionCount = overviews.filter(o => o.hasWarning).length;
+
+ // Average progress (kept for backwards compatibility)
+ const avgProgress = overviews.length > 0 ? Math.round(overviews.reduce((acc, o) => acc + o.progressPercent, 0) / overviews.length) : 0;
// On-Time projects vs Total
const onTimeCount = overviews.filter(o => o.healthStatus === 'On Track' || o.healthStatus === 'Completed' || o.healthStatus === 'Near Go-live').length;
@@ -838,6 +882,7 @@ export function calculateDashboardStats(assignments: IProjectAssignment[]) {
totalProjects: totalProjects || totalAssignments,
activeWorkOrders: activeWorkOrders || totalAssignments,
assignedPeople: assignedPeopleCount,
+ needsAttention: needsAttentionCount,
averageProgress: avgProgress,
onTimeRatio: `${onTimeCount} / ${totalAssignments}`,
atRiskDelayed: atRiskCount,
diff --git a/package.json b/package.json
index 58bd47b..b401e1b 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,7 @@
"framer-motion": "^12.23.25",
"get-orientation": "^1.1.2",
"heic2any": "^0.0.4",
- "lucide-react": "^1.49.0",
+ "lucide-react": "^1.68.0",
"motion": "^12.38.0",
"next": "^16.0.10",
"next-auth": "^4.24.13",
@@ -93,4 +93,4 @@
"tw-animate-css": "^1.4.0",
"typescript": "^5"
}
-}
\ No newline at end of file
+}