From a991f114efcaa2e385df610df8cdc18c518b5fe0 Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan <43689091+ichsankurnia@users.noreply.github.com> Date: Sat, 17 Oct 2026 21:26:05 +0700 Subject: [PATCH] Show assignment progress and latest activity Add actual progress and latest activity details to assignment grid and list views, and show linked project names in the list. Remove a debug log from the assignment detail page. --- .../[client_id]/[assignment_id]/page.tsx | 2 - .../project-assignment/AssignmentGrid.tsx | 33 ++++++++-- .../project-assignment/AssignmentList.tsx | 61 +++++++++++++++---- .../task/utils/assignment-overview-helpers.ts | 46 ++++++++++++++ 4 files changed, 124 insertions(+), 18 deletions(-) diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx index 608b5b0..5310544 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx @@ -15,8 +15,6 @@ export default async function AssignmentDetailPage({ params }: Props) { const [client, assignment] = await Promise.all([getClientById, getAssignmentById]); - console.log(assignment) - // 3. Handle 404 Securely on the server if (!assignment) { return ( diff --git a/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx b/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx index 28ae833..1f2e4b0 100644 --- a/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx +++ b/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx @@ -11,7 +11,7 @@ import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; import { LazyImage } from '@/components/ui/lazy-image'; -import { Calendar, MoreVertical, ArrowUpRight } from 'lucide-react'; +import { Calendar, MoreVertical, ArrowUpRight, Clock } from 'lucide-react'; import Link from 'next/link'; import { cn } from '@/lib/utils'; import ConvertedAssignmentBadge from './ConvertedAssignmentBadge'; @@ -287,21 +287,39 @@ export default function AssignmentGrid({ {/* Progress & Stepper Section */}
+ {/* Actual Progress (Real Work) matching detail page styling */}
- {item.daysRatioText} + + Actual + +
+
+
+ {item.actualProgress}% +
+ + {/* Days ratio, Dynamic color Progress bar & Percentage */} +
+ {item.daysRatioText}
- {item.progressPercent}% + {item.progressPercent}%
- {/* Footer: Delivery Health Badge & Team Avatars */} + {/* Footer: Delivery Health Badge, Schedule, Latest Activity & Team Avatars */}
{item.healthStatus}

{item.remainingText}

+

+ + {item.latestActivityText} +

diff --git a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx index 038779e..4eecdb3 100644 --- a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx +++ b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx @@ -11,7 +11,7 @@ import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; import { LazyImage } from '@/components/ui/lazy-image'; -import { Calendar, MoreVertical, ArrowUpRight } from 'lucide-react'; +import { Calendar, MoreVertical, ArrowUpRight, Clock, FolderGit2 } from 'lucide-react'; import Link from 'next/link'; import { cn } from '@/lib/utils'; import ConvertedAssignmentBadge from './ConvertedAssignmentBadge'; @@ -187,6 +187,23 @@ export default function AssignmentList({
+ {assignment.project?.name && ( +
+ + Project: + {projectDetailUrl ? ( + + {assignment.project.name} + + ) : ( + {assignment.project.name} + )} +
+ )} + {/* Line 3: End User & Timeline with Tooltips */}
{item.endUserName && ( @@ -225,18 +242,35 @@ export default function AssignmentList({
- {/* 2. CENTER: Progress Bar & 5-Node Stepper Track */} -
+ {/* 2. CENTER: Progress Bars (Actual Progress & Timeline) & 5-Node Stepper Track */} +
+ {/* Actual Progress (Real Work) matching detail page styling */} +
+ + Actual + +
+
+
+ {item.actualProgress}% +
+ {/* Days ratio, Dynamic color Progress bar & Percentage */}
- {item.daysRatioText} -
+ {item.daysRatioText} +
- {item.progressPercent}% + {item.progressPercent}%
{/* 5-Node Milestone Stepper Rail */} @@ -282,7 +316,7 @@ export default function AssignmentList({ {/* 4. RIGHT: Delivery Health Badge, Schedule, Next Step & Updated */}
-
+
{/* Health Badge */}
{item.remainingText}

- {/* Next Milestone & Timestamp */} -
- {item.nextMilestoneText} - {item.updatedAgoText} -
+ {/* Latest Activity Wording */} +

+ + {item.latestActivityText} +

{/* 5. ACTIONS: Vertical 3-dots Menu */} diff --git a/app/(dashboard)/task/utils/assignment-overview-helpers.ts b/app/(dashboard)/task/utils/assignment-overview-helpers.ts index 798df77..eb5551a 100644 --- a/app/(dashboard)/task/utils/assignment-overview-helpers.ts +++ b/app/(dashboard)/task/utils/assignment-overview-helpers.ts @@ -137,6 +137,7 @@ export interface AssignmentOverview { totalDays: number; daysRatioText: string; progressPercent: number; + actualProgress: number; progressColor: ProgressColorConfig; // Team @@ -155,6 +156,7 @@ export interface AssignmentOverview { remainingText: string; nextMilestoneText: string; updatedAgoText: string; + latestActivityText: string; } export function formatAssignmentDate(dateStr?: string) { @@ -168,6 +170,42 @@ export function formatAssignmentDate(dateStr?: string) { return `${day} ${month} ${year}`; } +export function formatHistoryRelativeTime(dateStr?: string | null): string { + if (!dateStr) return ''; + const d = dayjs(dateStr); + if (!d.isValid()) return ''; + const now = dayjs(); + const diffSec = Math.max(0, now.diff(d, 'second')); + + if (diffSec < 60) return 'just now'; + const diffMin = Math.floor(diffSec / 60); + if (diffMin < 60) return `${diffMin} ${diffMin === 1 ? 'minute' : 'minutes'} ago`; + const diffHours = Math.floor(diffMin / 60); + if (diffHours < 24) return `${diffHours} ${diffHours === 1 ? 'hour' : 'hours'} ago`; + const diffDays = Math.floor(diffHours / 24); + if (diffDays < 7) return `${diffDays} ${diffDays === 1 ? 'day' : 'days'} ago`; + const diffWeeks = Math.floor(diffDays / 7); + if (diffWeeks < 4) return diffWeeks === 1 ? 'a week ago' : `${diffWeeks} weeks ago`; + const diffMonths = Math.floor(diffDays / 30); + if (diffMonths < 12) return diffMonths === 1 ? 'a month ago' : `${diffMonths} months ago`; + const diffYears = Math.floor(diffDays / 365); + return diffYears === 1 ? 'a year ago' : `${diffYears} years ago`; +} + +export function formatLatestActivityWording(historyList?: any[] | null): string { + if (!historyList || !Array.isArray(historyList) || historyList.length === 0) { + return 'No updated activity'; + } + const latest = historyList[0]; + if (!latest || !latest.created_at) return 'No updated activity'; + + const rel = formatHistoryRelativeTime(latest.created_at); + if (!rel) return 'No updated activity'; + + const user = latest.user?.nickname || latest.user?.fullname || 'system'; + return `Updated ${rel} by ${user}`; +} + export function formatRelativeTime(dateStr?: string): string { if (!dateStr) return 'Updated 1 day ago'; const d = new Date(dateStr); @@ -723,6 +761,12 @@ 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 latestActivityText = formatLatestActivityWording(assignment.project_assignment_history); + return { assignmentType, isProject, @@ -741,6 +785,7 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num totalDays, daysRatioText, progressPercent, + actualProgress, progressColor, teamCount, teamMembers, @@ -750,6 +795,7 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num remainingText, nextMilestoneText, updatedAgoText, + latestActivityText, }; }