Add live milestone timelines to client views

Show upcoming assignment milestones with grouped agenda details and status-based colors. Use API status counts for client stage summaries and align status indicators across project timelines.
This commit is contained in:
Ichsan Kurniawan
2026-10-15 18:52:32 +07:00
parent 1953c28632
commit 09a049ce98
11 changed files with 727 additions and 357 deletions
@@ -35,12 +35,22 @@ export function DevelopmentActivityLog({ history = [] }: DevelopmentActivityLogP
const getDotColor = (index: number, desc: string) => {
const lower = desc.toLowerCase();
// Technical status progression colors matching badge variants
if (lower.includes('development') || lower.includes('dev')) return 'bg-rose-400 dark:bg-rose-600';
if (lower.includes('system integration') || lower.includes('sit')) return 'bg-orange-400 dark:bg-orange-600';
if (lower.includes('user acceptance') || lower.includes('uat')) return 'bg-yellow-400 dark:bg-yellow-500';
if (lower.includes('production trial') || lower.includes('ptr')) return 'bg-emerald-400 dark:bg-emerald-600';
if (lower.includes('go-live') || lower.includes('go live')) return 'bg-cyan-400 dark:bg-cyan-600';
if (lower.includes('bast') || lower.includes('handover')) return 'bg-violet-400 dark:bg-violet-600';
if (lower.includes('warranty')) return 'bg-fuchsia-400 dark:bg-fuchsia-600';
// Administrative and other events
if (lower.includes('create')) return 'bg-emerald-500';
if (lower.includes('assign')) return 'bg-sky-500';
if (lower.includes('status to active') || lower.includes('status to completed')) return 'bg-emerald-500';
if (lower.includes('on hold') || lower.includes('issue')) return 'bg-rose-500';
if (lower.includes('sit') || lower.includes('uat')) return 'bg-purple-500';
const colors = ['bg-emerald-500', 'bg-sky-500', 'bg-rose-500', 'bg-amber-500', 'bg-indigo-500'];
if (lower.includes('on hold') || lower.includes('issue')) return 'bg-amber-500';
const colors = ['bg-rose-400', 'bg-orange-400', 'bg-yellow-400', 'bg-emerald-400', 'bg-cyan-400', 'bg-violet-400', 'bg-fuchsia-400'];
return colors[index % colors.length];
};
@@ -222,15 +222,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'start' && (
<>
<div className="flex-1 h-0.75 bg-[#ea512c]" />
<div className="flex-1 h-0.75 bg-rose-400 dark:bg-rose-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -240,23 +240,23 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Red Line connecting Start to Development */}
<div className="flex-1 h-0.75 bg-[#ea512c]" />
{/* Continuous Rose Line connecting Start to Development */}
<div className="flex-1 h-0.75 bg-rose-400 dark:bg-rose-600" />
{/* 2. DEVELOPMENT SECTION */}
{devDates.length > 0 ? (
devDates.map((dStr, idx) => (
<div key={`dev-${idx}`} className="contents">
{idx > 0 && <div className="flex-1 h-0.75 bg-[#ea512c]" />}
{idx > 0 && <div className="flex-1 h-0.75 bg-rose-400 dark:bg-rose-600" />}
<div className="relative shrink-0 flex flex-col items-center">
{idx === 0 && (
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-semibold whitespace-nowrap ${isDevActive ? 'text-[#ea512c]' : 'text-foreground/90'}`}>
<span className={`text-xs font-semibold whitespace-nowrap ${isDevActive ? 'text-rose-500 dark:text-rose-400' : 'text-foreground/90'}`}>
Development
</span>
</div>
)}
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#ea512c] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-rose-400 dark:border-rose-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
{dStr}
@@ -268,25 +268,25 @@ export function ProjectMilestoneTimeline({
) : (
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-semibold whitespace-nowrap ${isDevActive ? 'text-[#ea512c]' : 'text-foreground/90'}`}>
<span className={`text-xs font-semibold whitespace-nowrap ${isDevActive ? 'text-rose-500 dark:text-rose-400' : 'text-foreground/90'}`}>
Development
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#ea512c] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-rose-400 dark:border-rose-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
</div>
)}
{insertTodayAfter === 'dev' && (
<>
<div className="flex-1 h-0.75 bg-[#ea512c]" />
<div className="flex-1 h-0.75 bg-rose-400 dark:bg-rose-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -296,17 +296,17 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Blue Line connecting to SIT */}
<div className="flex-1 h-0.75 bg-[#3b82f6]" />
{/* Continuous Orange Line connecting to SIT */}
<div className="flex-1 h-0.75 bg-orange-400 dark:bg-orange-600" />
{/* 3. SIT NODE */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isSitActive ? 'text-[#3b82f6] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isSitActive ? 'text-orange-500 dark:text-orange-400 font-semibold' : 'text-foreground'}`}>
SIT
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#3b82f6] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-orange-400 dark:border-orange-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
{sitDateFormatted && (
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
@@ -318,15 +318,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'sit' && (
<>
<div className="flex-1 h-0.75 bg-[#3b82f6]" />
<div className="flex-1 h-0.75 bg-orange-400 dark:bg-orange-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -336,17 +336,17 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Purple Line connecting to UAT */}
<div className="flex-1 h-0.75 bg-[#a855f7]" />
{/* Continuous Yellow Line connecting to UAT */}
<div className="flex-1 h-0.75 bg-yellow-400 dark:bg-yellow-500" />
{/* 4. UAT NODE */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isUatActive ? 'text-[#a855f7] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isUatActive ? 'text-yellow-600 dark:text-yellow-400 font-semibold' : 'text-foreground'}`}>
UAT
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#a855f7] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-yellow-400 dark:border-yellow-500 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
{uatDateFormatted && (
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
@@ -358,15 +358,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'uat' && (
<>
<div className="flex-1 h-0.75 bg-[#a855f7]" />
<div className="flex-1 h-0.75 bg-yellow-400 dark:bg-yellow-500" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -376,17 +376,17 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Teal Line connecting to PTR */}
<div className="flex-1 h-0.75 bg-[#14b8a6]" />
{/* Continuous Emerald Line connecting to PTR */}
<div className="flex-1 h-0.75 bg-emerald-400 dark:bg-emerald-600" />
{/* 5. PTR NODE */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isPtrActive ? 'text-[#14b8a6] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isPtrActive ? 'text-emerald-500 dark:text-emerald-400 font-semibold' : 'text-foreground'}`}>
PTR
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#14b8a6] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-emerald-400 dark:border-emerald-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
{ptrDateFormatted && (
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
@@ -398,15 +398,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'ptr' && (
<>
<div className="flex-1 h-0.75 bg-[#14b8a6]" />
<div className="flex-1 h-0.75 bg-emerald-400 dark:bg-emerald-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -416,17 +416,17 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Green Line connecting to Go Live */}
<div className="flex-1 h-0.75 bg-[#22c55e]" />
{/* Continuous Cyan Line connecting to Go Live */}
<div className="flex-1 h-0.75 bg-cyan-400 dark:bg-cyan-600" />
{/* 6. GO LIVE NODE */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isGoLiveActive ? 'text-[#22c55e] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isGoLiveActive ? 'text-cyan-500 dark:text-cyan-400 font-semibold' : 'text-foreground'}`}>
Go Live
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#22c55e] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-cyan-400 dark:border-cyan-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
{goLiveDateFormatted && (
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
@@ -438,15 +438,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'golive' && (
<>
<div className="flex-1 h-0.75 bg-[#22c55e]" />
<div className="flex-1 h-0.75 bg-cyan-400 dark:bg-cyan-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -456,17 +456,17 @@ export function ProjectMilestoneTimeline({
</>
)}
{/* Continuous Yellow Line connecting to BAST */}
<div className="flex-1 h-0.75 bg-[#eab308]" />
{/* Continuous Violet Line connecting to BAST */}
<div className="flex-1 h-0.75 bg-violet-400 dark:bg-violet-600" />
{/* 7. BAST NODE */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isBastActive ? 'text-[#eab308] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isBastActive ? 'text-violet-500 dark:text-violet-400 font-semibold' : 'text-foreground'}`}>
BAST
</span>
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#eab308] bg-white z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-violet-400 dark:border-violet-600 bg-white dark:bg-zinc-900 z-10 shadow-xs" />
{bastDateFormatted && (
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
@@ -478,15 +478,15 @@ export function ProjectMilestoneTimeline({
{insertTodayAfter === 'bast' && (
<>
<div className="flex-1 h-0.75 bg-[#eab308]" />
<div className="flex-1 h-0.75 bg-violet-400 dark:bg-violet-600" />
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-10 flex flex-col items-center pointer-events-none z-20">
<div className="rounded-full bg-[#ea512c] px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
Today
</div>
<div className="w-0.5 h-3 bg-[#ea512c]" />
<div className="w-0.5 h-3 bg-his" />
</div>
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] z-10 shadow-xs" />
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-10 shadow-xs" />
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
{todayFormatted}
@@ -502,15 +502,15 @@ export function ProjectMilestoneTimeline({
{/* 8. WARRANTY CAPSULE TRACK */}
<div className="relative shrink-0 flex flex-col items-center">
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
<span className={`text-xs font-medium whitespace-nowrap ${isWarrantyActive ? 'text-[#0ea5e9] font-semibold' : 'text-foreground'}`}>
<span className={`text-xs font-medium whitespace-nowrap ${isWarrantyActive ? 'text-fuchsia-500 dark:text-fuchsia-400 font-semibold' : 'text-foreground'}`}>
Warranty
</span>
</div>
{/* Capsule with < ---- > indicator matching Sky Blue techWarranty */}
<div className="flex items-center justify-between rounded-full border border-sky-500/40 bg-sky-500/10 px-2.5 py-0.5 text-sky-400 w-36 sm:w-44 z-10">
<ChevronLeft className="h-3 w-3 text-sky-400" />
<div className="h-0.5 flex-1 bg-sky-500/60 mx-1" />
<ChevronRight className="h-3 w-3 text-sky-400" />
{/* Capsule with < ---- > indicator matching Fuchsia techWarranty */}
<div className="flex items-center justify-between rounded-full border border-fuchsia-400/50 dark:border-fuchsia-500/40 bg-fuchsia-400/10 dark:bg-fuchsia-500/10 px-2.5 py-0.5 text-fuchsia-500 dark:text-fuchsia-400 w-36 sm:w-44 z-10">
<ChevronLeft className="h-3 w-3 text-fuchsia-500 dark:text-fuchsia-400" />
<div className="h-0.5 flex-1 bg-fuchsia-400/60 dark:bg-fuchsia-500/60 mx-1" />
<ChevronRight className="h-3 w-3 text-fuchsia-500 dark:text-fuchsia-400" />
</div>
{/* Dates below warranty: strictly empty if not set */}
{(warrantyStart || warrantyEnd) && (
@@ -3,7 +3,7 @@
import { motion } from 'motion/react';
import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle, CardDescription, Card900 } from '@/components/ui/card';
import { Card, CardContent, CardHeader, CardTitle, Card900 } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Separator } from '@/components/ui/separator';
import { Label } from '@/components/ui/label';
@@ -161,7 +161,7 @@ export default function ProjectDetailComponent({ client, project }: Props) {
<div className="w-2 h-2 rounded-full bg-primary mt-1.5 shrink-0" />
<div>
<div className="flex items-center gap-2">
<span className="font-bold">{history.project_assignment_status.name}</span>
<BadgeStatus status={history.project_assignment_status.name} />
<span className="text-muted-foreground text-xs">{new Date(history.updated_at!).toLocaleDateString()}</span>
</div>
{/* <p className="text-muted-foreground text-xs mt-0.5">{history.status_remarks}</p> */}
@@ -14,6 +14,19 @@ interface StatusTimelineProps {
const TIMELINE_PREVIEW_LIMIT = 3;
function getStatusDotColor(name?: string | null): string {
if (!name) return 'bg-his';
const lower = name.toLowerCase();
if (lower.includes('development') || lower.includes('dev')) return 'bg-rose-400 dark:bg-rose-600';
if (lower.includes('system integration') || lower.includes('sit')) return 'bg-orange-400 dark:bg-orange-600';
if (lower.includes('user acceptance') || lower.includes('uat')) return 'bg-yellow-400 dark:bg-yellow-500';
if (lower.includes('production trial') || lower.includes('ptr')) return 'bg-emerald-400 dark:bg-emerald-600';
if (lower.includes('go-live') || lower.includes('go live')) return 'bg-cyan-400 dark:bg-cyan-600';
if (lower.includes('bast') || lower.includes('handover')) return 'bg-violet-400 dark:bg-violet-600';
if (lower.includes('warranty')) return 'bg-fuchsia-400 dark:bg-fuchsia-600';
return 'bg-his';
}
export default function StatusTimeline({ history }: StatusTimelineProps) {
const [showAll, setShowAll] = useState(false);
@@ -68,7 +81,7 @@ export default function StatusTimeline({ history }: StatusTimelineProps) {
aria-hidden
className={cn(
'absolute left-0 top-1 h-3.75 w-3.75 rounded-full border-[3px] border-card',
isCurrent ? 'bg-his' : 'bg-muted-foreground/40'
isCurrent ? getStatusDotColor(entry.project_assignment_status?.name) : 'bg-muted-foreground/40'
)}
/>
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
@@ -281,18 +281,18 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
<label className="text-xs font-medium text-foreground">
Description & Progress Notes for this Interval
</label>
<span className="text-[11px] text-muted-foreground">{description.length}/500</span>
<span className="text-[11px] text-muted-foreground">{description.length}/250</span>
</div>
<Textarea
value={description}
onChange={(e) => setDescription(e.target.value)}
maxLength={500}
maxLength={250}
rows={3}
placeholder="Deskripsi kegiatan atau milestone untuk interval tanggal ini..."
placeholder="Description of activities or milestones for these dates..."
className="text-sm resize-none"
/>
<p className="text-[11px] text-muted-foreground">
Deskripsi ini khusus berlaku untuk rentang tanggal di atas.
This description is specifically for the date range above.
</p>
</div>
</div>
@@ -18,7 +18,8 @@ import {
import BadgeStatus from '@/components/ui/badge-status';
import { cn } from '@/lib/utils';
import { IClient, CLIENT_FALLBACK_IMAGE } from '../../types';
import { getProjectStatusBreakdown, getClientMilestones } from '../../utils/client-overview-helpers';
import { getProjectStatusBreakdown } from '../../utils/client-overview-helpers';
import ClientMilestoneTimeline from './ClientMilestoneTimeline';
interface ClientGridProps {
clients: IClient[];
@@ -32,17 +33,13 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
{clients.map((client, i) => {
const isActive = (client.status_name || '').toLowerCase() === 'active';
const stages = getProjectStatusBreakdown(client);
const milestones = getClientMilestones(client);
const activeMilestone = milestones[1] || milestones[0];
const totalProjects = client.total_project ?? 0;
const assignedPeople = client.total_user_assigned || client.users?.length || 0;
const activeWorkOrders = client.total_work_order ?? 0;
// Pick top stages with activity (or top 3)
const topStages = stages.filter((s) => s.count > 0).slice(0, 7);
const displayStages = topStages.length > 0 ? topStages : stages.slice(0, 7);
const maxStageCount = Math.max(...displayStages.map((s) => s.count), 1);
// Display all 7 stages
const maxStageCount = 10;
return (
<motion.div
@@ -197,8 +194,8 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
<span className="text-[10px] text-muted-foreground font-normal">Active Stages</span>
</div>
<div className="space-y-1.5">
{displayStages.map((stage) => {
const barPercent = stage.count > 0 ? Math.max(16, (stage.count / maxStageCount) * 100) : 0;
{stages.map((stage) => {
const barPercent = Math.min(100, (stage.count / maxStageCount) * 100);
return (
<div key={stage.id} className="flex items-center gap-2 text-xs">
<div className="flex items-center gap-1.5 w-32 shrink-0 truncate">
@@ -220,6 +217,11 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
</div>
</div>
{/* Next 2 Months Milestone Timeline */}
<div className="pt-2 border-t border-border/40">
<ClientMilestoneTimeline client={client} variant="grid" />
</div>
</div>
{/* Card Bottom: Team Avatars & View Detail button */}
@@ -18,7 +18,8 @@ import {
import BadgeStatus from '@/components/ui/badge-status';
import { cn } from '@/lib/utils';
import { IClient, CLIENT_FALLBACK_IMAGE } from '../../types';
import { getProjectStatusBreakdown, getClientMilestones } from '../../utils/client-overview-helpers';
import { getProjectStatusBreakdown } from '../../utils/client-overview-helpers';
import ClientMilestoneTimeline from './ClientMilestoneTimeline';
interface ClientListProps {
clients: IClient[];
@@ -32,8 +33,7 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp
{clients.map((client, index) => {
const isActive = (client.status_name || '').toLowerCase() === 'active';
const stages = getProjectStatusBreakdown(client);
const milestones = getClientMilestones(client);
const maxStageCount = Math.max(...stages.map((s) => s.count), 1);
const maxStageCount = 10;
const totalProjects = client.total_project ?? 0;
const assignedPeople = client.total_user_assigned || client.users?.length || 0;
@@ -175,7 +175,7 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp
<div className="space-y-1.5 pt-0.5">
{stages.map((stage) => {
const barPercent = stage.count > 0 ? Math.max(14, (stage.count / maxStageCount) * 100) : 0;
const barPercent = Math.min(100, (stage.count / maxStageCount) * 100);
return (
<div key={stage.id} className="flex items-center gap-2 sm:gap-3 text-xs">
{/* Stage Name + Dot matching technical status */}
@@ -275,83 +275,9 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp
</div>
</div>
{/* Bottom Section: Milestone Roadmap matching exact layout & color of the image */}
{/* Bottom Section: 2-Month Milestone Timeline */}
<div className="pt-3 border-t border-border/50">
<div className="flex flex-col lg:flex-row lg:items-center gap-4 lg:gap-8">
{/* Left Label: On same horizontal row */}
<div className="shrink-0 lg:w-44 xl:w-48">
<span className="text-xs sm:text-sm font-semibold text-foreground/90 tracking-tight">
Next 2 Months Milestone
</span>
</div>
{/* Right Timeline: Month headers + Track with capsules & dates below */}
<div className="flex-1 min-w-0 overflow-x-auto scrollbar-hide">
<div className="min-w-160 flex flex-col gap-1.5">
{/* Month Headers */}
<div className="flex items-center text-[11px] font-semibold text-muted-foreground px-4">
<div className="w-[60%] text-center">Oct 2026</div>
<div className="w-[40%] text-center">Nov 2026</div>
</div>
{/* Continuous Track */}
<div className="flex items-start justify-between relative pt-0.5">
{milestones.map((m, mIdx) => (
<div key={m.id} className="flex items-center flex-1 last:flex-none">
{/* Node + Capsule + Date underneath */}
<div className="flex flex-col items-center gap-1.5 shrink-0 z-10">
{/* Row of Emblem Circle + Capsule */}
<div className="flex items-center gap-1.5">
{/* Circular emblem node */}
<div
className={cn(
"size-6 md:size-7 rounded-full bg-white dark:bg-zinc-900 border-2 shadow-xs flex items-center justify-center shrink-0 overflow-hidden",
m.nodeBorderColor
)}
>
<LazyImage
src={client.photo}
fallbackSrc={CLIENT_FALLBACK_IMAGE}
alt={client.name}
className="h-full w-auto bg-transparent"
imgClassName="object-contain h-full group-hover/logo:scale-105 transition-transform"
/>
</div>
{/* Capsule Pill (Phase Name only) */}
<div
className={cn(
"px-3.5 py-1 rounded-full border text-center font-bold text-xs shadow-xs transition-transform hover:scale-105 shrink-0 min-w-14",
m.capsuleBg,
m.capsuleBorder,
m.capsuleText
)}
>
{m.phase}
</div>
</div>
{/* Date Range strictly UNDER the capsule */}
<div className="text-[10px] text-zinc-700 dark:text-zinc-200 font-medium whitespace-nowrap text-center">
{m.dateRange}
</div>
</div>
{/* Connecting Line Segment between nodes */}
{mIdx < milestones.length - 1 && (
<div
className={cn(
"flex-1 h-0.5 min-w-4 sm:min-w-6 self-start mt-3.5",
m.lineColor
)}
/>
)}
</div>
))}
</div>
</div>
</div>
</div>
<ClientMilestoneTimeline client={client} variant="list" />
</div>
</Card900>
</motion.div>
@@ -0,0 +1,320 @@
"use client";
import React from 'react';
import Link from 'next/link';
import dayjs from 'dayjs';
import { Calendar, ChevronRight, Clock } from 'lucide-react';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card';
import BadgeStatus from '@/components/ui/badge-status';
import { cn } from '@/lib/utils';
import { IClient, IClientMilestone } from '../../types';
import { resolveTechnicalStatusMeta } from '../../utils/client-overview-helpers';
interface ClientMilestoneTimelineProps {
client: IClient;
variant?: 'list' | 'grid';
}
interface GroupedMilestone {
dateKey: string;
date: dayjs.Dayjs;
percent: number;
diffDays: number;
items: IClientMilestone[];
}
export default function ClientMilestoneTimeline({ client, variant = 'list' }: ClientMilestoneTimelineProps) {
const today = dayjs().startOf('day');
const maxDate = today.add(2, 'month').startOf('day');
const totalDays = maxDate.diff(today, 'day') || 60;
// Filter milestones whose start_date is within the 2-month range [today, today + 2 months]
const rawMilestones = client.milestone || [];
const validMilestones = rawMilestones.filter((m) => {
if (!m.start_date) return false;
const mDate = dayjs(m.start_date).startOf('day');
const diff = mDate.diff(today, 'day');
return diff >= 0 && diff <= totalDays;
});
// Group milestones by start_date to handle multiple agendas on the exact same date
const groupsMap: { [key: string]: GroupedMilestone } = {};
validMilestones.forEach((item) => {
const mDate = dayjs(item.start_date).startOf('day');
const dateKey = mDate.format('YYYY-MM-DD');
const diffDays = mDate.diff(today, 'day');
const rawPercent = (diffDays / totalDays) * 100;
const percent = Math.max(0, Math.min(100, rawPercent));
if (!groupsMap[dateKey]) {
groupsMap[dateKey] = {
dateKey,
date: mDate,
percent,
diffDays,
items: [],
};
}
groupsMap[dateKey].items.push(item);
});
const groups = Object.values(groupsMap).sort((a, b) => a.diffDays - b.diffDays);
// Compute month boundaries for tick lines along the 2-month rail
const nextMonthStart = today.add(1, 'month').startOf('month');
const month2Start = today.add(2, 'month').startOf('month');
const monthTicks: { label: string; percent: number }[] = [];
if (nextMonthStart.isAfter(today) && nextMonthStart.isBefore(maxDate)) {
const diff = nextMonthStart.diff(today, 'day');
monthTicks.push({
label: nextMonthStart.format('1 MMM'),
percent: (diff / totalDays) * 100,
});
}
if (month2Start.isAfter(today) && month2Start.isBefore(maxDate)) {
const diff = month2Start.diff(today, 'day');
monthTicks.push({
label: month2Start.format('1 MMM'),
percent: (diff / totalDays) * 100,
});
}
const isGrid = variant === 'grid';
console.log(groups)
return (
<div className={cn("w-full flex flex-col gap-2 min-w-0", isGrid ? "pt-2" : "")}>
{/* Header: Title + 2-Month Date Span */}
<div className="flex items-center justify-between text-xs px-0.5">
<div className="flex items-center gap-2 flex-wrap">
<span className="font-semibold text-foreground tracking-tight text-xs">
Next 2 Months Milestone
</span>
<span className="text-[10px] text-muted-foreground font-medium hidden sm:inline">
({today.format('DD MMM')} – {maxDate.format('DD MMM YYYY')})
</span>
</div>
<div className="flex items-center gap-1.5">
{groups.length > 0 ? (
<span className="text-[10px] px-2 py-0.5 rounded-full bg-primary/10 text-primary font-bold">
{validMilestones.length} {validMilestones.length === 1 ? 'Agenda' : 'Agendas'}
</span>
) : (
<span className="text-[10px] text-muted-foreground italic">
No milestone scheduled
</span>
)}
</div>
</div>
{/* Timeline Viewport Container */}
<div className={cn("w-full min-w-0", isGrid ? "" : "overflow-x-auto scrollbar-hide")}>
<div className={cn("relative pt-3", groups.length > 0 ? 'mb-14' : 'mb-4', isGrid ? "px-3" : "min-w-105 px-6")}>
{/* Continuous 2-Month Horizontal Rail */}
<div className="relative h-1.5 w-full bg-muted/70 dark:bg-zinc-800 rounded-full">
{/* Start Pin (Today) */}
<div
className="absolute -left-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full bg-primary/40 ring-2 ring-background"
title={`Today: ${today.format('DD MMM YYYY')}`}
/>
{/* End Pin (+2 Months) */}
<div
className="absolute -right-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full bg-muted-foreground/40 ring-2 ring-background"
title={`End: ${maxDate.format('DD MMM YYYY')}`}
/>
{/* Month Boundary Tick Markers */}
{monthTicks.map((tick, idx) => (
<div
key={idx}
className="absolute -top-1 -translate-x-1/2 flex flex-col items-center pointer-events-none select-none z-0"
style={{ left: `${tick.percent}%` }}
>
<div className="w-px h-3.5 bg-border/80 dark:bg-zinc-700" />
<span className="text-[9px] text-muted-foreground/70 font-mono mt-0.5 whitespace-nowrap">
{tick.label}
</span>
</div>
))}
{/* If no milestones in range, show gentle notice */}
{groups.length === 0 && (
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
<span className="text-[10px] text-muted-foreground/70 italic mt-6 select-none whitespace-nowrap">
No upcoming milestones in the next 2 months
</span>
</div>
)}
{/* Agenda Milestone Markers */}
{groups.map((group) => {
const isMulti = group.items.length > 1;
const firstItem = group.items[0];
const primaryMeta = resolveTechnicalStatusMeta(firstItem.project_assignment_status?.name);
return (
<div
key={group.dateKey}
className="absolute -translate-x-1/2 -top-1 z-20 flex flex-col items-center group/node"
style={{ left: `${group.percent}%` }}
>
{/* Vertical Tick Line connecting Rail to Dot */}
<div
className={cn(
"w-0.5 h-3.5 sm:h-4 rounded-full transition-all duration-200 group-hover/node:scale-y-125",
isMulti ? "bg-amber-400 dark:bg-amber-500" : primaryMeta.tickLine
)}
/>
{/* HoverCard Trigger (Dot + Short Badge + Date) */}
<HoverCard openDelay={40} closeDelay={150}>
<HoverCardTrigger asChild>
<Link
href={`/task/client-detail/${client.id}/${firstItem.project_assignment_id}`}
className="flex flex-col items-center cursor-pointer transition-transform hover:scale-110 focus:outline-none hover:bg-white hover:z-9999"
aria-label={`Milestones on ${group.date.format('DD MMM YYYY')}`}
>
{/* Dot / Multi-Dot Indicator */}
{isMulti ? (
<div
className="relative size-4 sm:size-4.5 rounded-full bg-linear-to-br from-amber-400 via-rose-500 to-violet-600 p-[1.5px] shadow-sm ring-2 ring-background hover:ring-primary/40 transition-shadow"
title={`${group.items.length} agendas on this date`}
>
<div className="w-full h-full rounded-full bg-background flex items-center justify-center">
<span className="text-[9px] font-black text-foreground leading-none">
{group.items.length}
</span>
</div>
</div>
) : (
<div
className={cn(
"size-3 sm:size-3.5 rounded-full ring-2 ring-background shadow-xs transition-all duration-200 group-hover/node:ring-4",
primaryMeta.dotBg,
primaryMeta.ringColor
)}
title={`${primaryMeta.fullName} on ${group.date.format('DD MMM YYYY')}`}
/>
)}
{/* Short Badge underneath dot */}
<div
className={cn(
"mt-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider border whitespace-nowrap shadow-2xs leading-none transition-colors",
isMulti
? "bg-amber-500/15 dark:bg-amber-950/60 text-amber-700 dark:text-amber-300 border-amber-500/40"
: cn(primaryMeta.badgeBg, primaryMeta.badgeText, primaryMeta.badgeBorder)
)}
>
{isMulti ? `${group.items.length} Agendas` : primaryMeta.shortName}
</div>
{/* Date Label strictly underneath */}
<span className="text-[9px] sm:text-[10px] text-muted-foreground font-medium whitespace-nowrap mt-0.5 select-none">
{group.date.format('DD MMM')}
</span>
</Link>
</HoverCardTrigger>
{/* Rich Hover Card Content */}
<HoverCardContent
side="top"
align="center"
sideOffset={8}
className="w-[calc(100vw-3rem)] max-w-sm sm:w-96 p-3.5 z-50 shadow-xl border border-border/80 bg-popover/95 backdrop-blur-md rounded-xl"
>
{/* Header */}
<div className="flex items-center justify-between pb-2 mb-2.5 border-b border-border/60">
<div className="flex items-center gap-1.5 text-foreground font-semibold text-xs">
<Calendar className="w-3.5 h-3.5 text-primary shrink-0" />
<span>{group.date.format('dddd, DD MMMM YYYY')}</span>
</div>
<span className="text-[10px] font-medium px-2 py-0.5 rounded-md bg-muted text-muted-foreground">
{group.diffDays === 0
? 'Today'
: group.diffDays === 1
? 'Tomorrow'
: `In ${group.diffDays} days`}
</span>
</div>
{/* Subtitle / Counter */}
<div className="text-[11px] text-muted-foreground mb-2">
{group.items.length === 1
? '1 milestone agenda on this date:'
: `${group.items.length} milestone agendas on this date:`}
</div>
{/* List of Assignment Milestones */}
<div className="space-y-2 max-h-64 overflow-y-auto pr-1">
{group.items.map((item, itemIdx) => (
<Link
key={item.id || itemIdx}
href={`/task/client-detail/${client.id}/${item.project_assignment_id}`}
className="group/item block p-2.5 rounded-lg border border-border/70 bg-muted/30 hover:bg-muted/60 hover:border-his/60 transition-all duration-200"
>
<div className="flex items-center justify-between gap-2">
<BadgeStatus status={item.project_assignment_status?.name} />
<span className="text-[10px] text-muted-foreground font-medium flex items-center gap-0.5 group-hover/item:text-foreground transition-colors">
<span>View Assignment</span>
<ChevronRight className="w-3 h-3 group-hover/item:translate-x-0.5 transition-transform" />
</span>
</div>
<div className="mt-2 space-y-1">
{item.project_name && (
<div className="text-xs font-semibold text-foreground truncate">
{item.project_name}
{item.project_code && (
<span className="ml-1 text-[10px] font-mono font-normal text-muted-foreground">
({item.project_code})
</span>
)}
</div>
)}
{item.wo_name && (
<div className="text-[11px] text-muted-foreground truncate">
WO: <span className="font-medium text-foreground">{item.wo_name}</span>
{item.wo_code && (
<span className="ml-1 text-[10px] font-mono text-muted-foreground/80">
[{item.wo_code}]
</span>
)}
</div>
)}
{item.description && (
<p className="text-[11px] text-muted-foreground italic line-clamp-2 mt-1">
&ldquo;{item.description}&rdquo;
</p>
)}
<div className="pt-1 flex items-center gap-1.5 text-[10px] text-muted-foreground">
<Clock className="w-3 h-3 shrink-0" />
<span>
{dayjs(item.start_date).format('DD MMM YYYY')}
{item.end_date
? ` – ${dayjs(item.end_date).format('DD MMM YYYY')}`
: ''}
</span>
</div>
</div>
</Link>
))}
</div>
</HoverCardContent>
</HoverCard>
</div>
);
})}
</div>
</div>
</div>
</div>
);
}
+1
View File
@@ -29,6 +29,7 @@ export default async function ClientsPage({ searchParams }: Props) {
const filteredClients = getFilteredClients(allClients, query, sortBy)
// const filterAssignments = getFilteredAssignments(allAssignments, query, sortBy)
console.log(allClients)
return (
<div className="flex-1 space-y-8 p-4 sm:p-8 pt-4 sm:pt-6">
+70 -45
View File
@@ -1,45 +1,70 @@
import { IUser } from "@/app/admin/administration/user/component/type";
export const CLIENT_FALLBACK_IMAGE = '/assets/illustrations/client_fallback.webp';
export const END_USER_FALLBACK_IMAGE = '/assets/illustrations/end_user_fallback.webp';
export type IEndUser = {
id?: string;
code?: string
name: string;
description: string;
photo?: string
status: {
id: number
code: string
name: string
}
};
export type IClient = {
id: number
code: string
name: string
photo: string
description: any
status_id: number
status_code: string
status_name: string
total_project: number
total_im?: number
total_work_order: number
total_user_assigned: number
users: IUser[]
project_status_summary: ProjectStatusSummary[]
created_at?: string
created_by?: number
updated_at?: string
updated_by?: number
deleted_at?: string
deleted_by?: number
};
export interface ProjectStatusSummary {
total: number
project_status: string
}
import { IUser } from "@/app/admin/administration/user/component/type";
export const CLIENT_FALLBACK_IMAGE = '/assets/illustrations/client_fallback.webp';
export const END_USER_FALLBACK_IMAGE = '/assets/illustrations/end_user_fallback.webp';
export type IEndUser = {
id?: string;
code?: string
name: string;
description: string;
photo?: string
status: {
id: number
code: string
name: string
}
};
export interface IClientMilestone {
id: number;
project_assignment_id: number;
project_assignment_status_id: number;
project_assignment_status?: {
id: number;
name: string;
description?: string;
};
start_date: string;
end_date: string;
description?: string;
project_name?: string;
project_code?: string;
wo_name?: string;
wo_code?: string;
}
export interface IClientProjectStatusToday {
status: string;
total: number;
}
export type IClient = {
id: number
code: string
name: string
photo: string
description: any
status_id: number
status_code: string
status_name: string
total_project: number
total_im?: number
total_work_order: number
total_user_assigned: number
users: IUser[]
milestone?: IClientMilestone[]
project_status_today?: IClientProjectStatusToday[]
project_status_summary: ProjectStatusSummary[]
created_at?: string
created_by?: number
updated_at?: string
updated_by?: number
deleted_at?: string
deleted_by?: number
};
export interface ProjectStatusSummary {
total: number
project_status: string
}
@@ -54,20 +54,32 @@ export function calculateOverviewStats(clients: IClient[]): OverviewStats {
/**
* Generates project lifecycle status breakdown (7 phases).
* Colors strictly match technical progression status from components/ui/badge.tsx:
* - Development: bg-his (#EA512C)
* - SIT: bg-blue-500
* - UAT: bg-purple-500
* - PTR: bg-teal-500
* - Go-live: bg-green-500
* - Handover & BAST: bg-yellow-500
* - Warranty: bg-sky-500
* - Development: bg-rose-400 dark:bg-rose-600
* - SIT: bg-orange-400 dark:bg-orange-700
* - UAT: bg-yellow-400 dark:bg-yellow-500
* - PTR: bg-emerald-400 dark:bg-emerald-600
* - Go-live: bg-cyan-400 dark:bg-cyan-600
* - Handover & BAST: bg-violet-400 dark:bg-violet-600
* - Warranty: bg-fuchsia-400 dark:bg-fuchsia-600
*/
export function getProjectStatusBreakdown(client: IClient): StatusStage[] {
const totalProjects = client.total_project || 0;
const todayStats = client.project_status_today || [];
const summary = client.project_status_summary || [];
// Helper to find count from real summary by keywords
// Helper to find count from real data by keywords
const findCount = (keywords: string[]): number => {
// Priority 1: Check project_status_today from API
if (todayStats && todayStats.length > 0) {
for (const item of todayStats) {
const status = (item.status || '').toLowerCase();
if (keywords.some((kw) => status.includes(kw))) {
return item.total ?? 0;
}
}
return 0;
}
// Priority 2: Fallback to project_status_summary if project_status_today is absent
let count = 0;
summary.forEach((item) => {
const status = (item.project_status || '').toLowerCase();
@@ -78,113 +90,174 @@ export function getProjectStatusBreakdown(client: IClient): StatusStage[] {
return count;
};
let devCount = findCount(['dev', 'development']);
let sitCount = findCount(['sit', 'system integration']);
let uatCount = findCount(['uat', 'user acceptance']);
let ptrCount = findCount(['ptr', 'production trial run']);
let liveCount = findCount(['live', 'go-live', 'complete']);
let handoverCount = findCount(['handover', 'bast']);
let warrantyCount = findCount(['warranty', 'maintenance']);
const hasAnyRealCount = devCount + sitCount + uatCount + ptrCount + liveCount + handoverCount + warrantyCount > 0;
// If client has projects but no specific phase breakdown in API, generate realistic dummy distribution
if (!hasAnyRealCount && totalProjects > 0) {
const seed = (client.id || 1) % 3;
if (seed === 0) {
devCount = Math.max(1, Math.floor(totalProjects * 0.4));
sitCount = Math.max(1, Math.floor(totalProjects * 0.3));
uatCount = Math.max(0, Math.floor(totalProjects * 0.2));
ptrCount = Math.max(0, totalProjects - devCount - sitCount - uatCount);
} else if (seed === 1) {
devCount = Math.max(1, Math.floor(totalProjects * 0.3));
sitCount = Math.max(1, Math.floor(totalProjects * 0.4));
uatCount = Math.max(1, Math.floor(totalProjects * 0.2));
ptrCount = Math.max(0, totalProjects - devCount - sitCount - uatCount);
} else {
devCount = Math.max(1, Math.floor(totalProjects * 0.35));
sitCount = Math.max(1, Math.floor(totalProjects * 0.35));
uatCount = Math.max(1, Math.floor(totalProjects * 0.2));
ptrCount = Math.max(0, totalProjects - devCount - sitCount - uatCount);
}
} else if (!hasAnyRealCount && totalProjects === 0 && (client.status_name || '').toLowerCase() === 'active') {
const seed = (client.id || 1) % 4;
if (seed === 0) {
devCount = 2;
sitCount = 1;
uatCount = 1;
ptrCount = 1;
} else if (seed === 1) {
devCount = 1;
sitCount = 2;
uatCount = 1;
ptrCount = 1;
} else if (seed === 2) {
devCount = 1;
sitCount = 1;
uatCount = 2;
ptrCount = 0;
} else {
devCount = 0;
sitCount = 0;
uatCount = 0;
ptrCount = 0;
}
}
const devCount = findCount(['dev', 'development']);
const sitCount = findCount(['sit', 'system integration']);
const uatCount = findCount(['uat', 'user acceptance']);
const ptrCount = findCount(['ptr', 'production trial run']);
const liveCount = findCount(['live', 'go-live', 'golive']);
const handoverCount = findCount(['handover', 'bast']);
const warrantyCount = findCount(['warranty', 'maintenance']);
return [
{
id: 'dev',
name: 'Development',
colorDot: 'bg-his',
colorBar: 'bg-his',
colorDot: 'bg-rose-400 dark:bg-rose-600',
colorBar: 'bg-rose-400 dark:bg-rose-600',
count: devCount,
},
{
id: 'sit',
name: 'System Integration Testing (SIT)',
colorDot: 'bg-blue-500',
colorBar: 'bg-blue-500',
colorDot: 'bg-orange-400 dark:bg-orange-700',
colorBar: 'bg-orange-400 dark:bg-orange-700',
count: sitCount,
},
{
id: 'uat',
name: 'User Acceptance Testing (UAT)',
colorDot: 'bg-purple-500',
colorBar: 'bg-purple-500',
colorDot: 'bg-yellow-400 dark:bg-yellow-500',
colorBar: 'bg-yellow-400 dark:bg-yellow-500',
count: uatCount,
},
{
id: 'ptr',
name: 'Production Trial Run (PTR)',
colorDot: 'bg-teal-500',
colorBar: 'bg-teal-500',
colorDot: 'bg-emerald-400 dark:bg-emerald-600',
colorBar: 'bg-emerald-400 dark:bg-emerald-600',
count: ptrCount,
},
{
id: 'golive',
name: 'Go-live',
colorDot: 'bg-green-500',
colorBar: 'bg-green-500',
name: 'Go-Live',
colorDot: 'bg-cyan-400 dark:bg-cyan-600',
colorBar: 'bg-cyan-400 dark:bg-cyan-600',
count: liveCount,
},
{
id: 'bast',
name: 'Project Handover & BAST',
colorDot: 'bg-yellow-500',
colorBar: 'bg-yellow-500',
colorDot: 'bg-violet-400 dark:bg-violet-600',
colorBar: 'bg-violet-400 dark:bg-violet-600',
count: handoverCount,
},
{
id: 'warranty',
name: 'Warranty',
colorDot: 'bg-sky-500',
colorBar: 'bg-sky-500',
colorDot: 'bg-fuchsia-400 dark:bg-fuchsia-600',
colorBar: 'bg-fuchsia-400 dark:bg-fuchsia-600',
count: warrantyCount,
},
];
}
export interface TechnicalStatusMeta {
shortName: string;
fullName: string;
dotBg: string;
dotBorder: string;
ringColor: string;
badgeBg: string;
badgeText: string;
badgeBorder: string;
tickLine: string;
}
export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatusMeta {
const s = (statusName || '').toLowerCase().trim();
if (s.includes('uat') || s.includes('user acceptance')) {
return {
shortName: 'UAT',
fullName: 'User Acceptance Testing (UAT)',
dotBg: 'bg-yellow-400 dark:bg-yellow-500',
dotBorder: 'border-yellow-300 dark:border-yellow-500',
ringColor: 'ring-yellow-400/30 dark:ring-yellow-500/30',
badgeBg: 'bg-yellow-400/15 dark:bg-yellow-500/20',
badgeText: 'text-yellow-700 dark:text-yellow-300',
badgeBorder: 'border-yellow-400/40 dark:border-yellow-500/40',
tickLine: 'bg-yellow-400 dark:bg-yellow-500',
};
}
if (s.includes('sit') || s.includes('system integration')) {
return {
shortName: 'SIT',
fullName: 'System Integration Testing (SIT)',
dotBg: 'bg-orange-400 dark:bg-orange-600',
dotBorder: 'border-orange-300 dark:border-orange-500',
ringColor: 'ring-orange-400/30 dark:ring-orange-600/30',
badgeBg: 'bg-orange-400/15 dark:bg-orange-600/20',
badgeText: 'text-orange-700 dark:text-orange-300',
badgeBorder: 'border-orange-400/40 dark:border-orange-600/40',
tickLine: 'bg-orange-400 dark:bg-orange-600',
};
}
if (s.includes('ptr') || s.includes('trial run')) {
return {
shortName: 'PTR',
fullName: 'Production Trial Run (PTR)',
dotBg: 'bg-emerald-400 dark:bg-emerald-600',
dotBorder: 'border-emerald-300 dark:border-emerald-500',
ringColor: 'ring-emerald-400/30 dark:ring-emerald-600/30',
badgeBg: 'bg-emerald-400/15 dark:bg-emerald-600/20',
badgeText: 'text-emerald-700 dark:text-emerald-300',
badgeBorder: 'border-emerald-400/40 dark:border-emerald-600/40',
tickLine: 'bg-emerald-400 dark:bg-emerald-600',
};
}
if (s.includes('live') || s.includes('go-live') || s.includes('golive')) {
return {
shortName: 'LIVE',
fullName: 'Go-Live',
dotBg: 'bg-cyan-400 dark:bg-cyan-600',
dotBorder: 'border-cyan-300 dark:border-cyan-500',
ringColor: 'ring-cyan-400/30 dark:ring-cyan-600/30',
badgeBg: 'bg-cyan-400/15 dark:bg-cyan-600/20',
badgeText: 'text-cyan-700 dark:text-cyan-300',
badgeBorder: 'border-cyan-400/40 dark:border-cyan-600/40',
tickLine: 'bg-cyan-400 dark:bg-cyan-600',
};
}
if (s.includes('bast') || s.includes('handover')) {
return {
shortName: 'BAST',
fullName: 'Project Handover & BAST',
dotBg: 'bg-violet-400 dark:bg-violet-600',
dotBorder: 'border-violet-300 dark:border-violet-500',
ringColor: 'ring-violet-400/30 dark:ring-violet-600/30',
badgeBg: 'bg-violet-400/15 dark:bg-violet-600/20',
badgeText: 'text-violet-700 dark:text-violet-300',
badgeBorder: 'border-violet-400/40 dark:border-violet-600/40',
tickLine: 'bg-violet-400 dark:bg-violet-600',
};
}
if (s.includes('warranty') || s.includes('maintenance')) {
return {
shortName: 'WAR',
fullName: 'Warranty',
dotBg: 'bg-fuchsia-400 dark:bg-fuchsia-600',
dotBorder: 'border-fuchsia-300 dark:border-fuchsia-500',
ringColor: 'ring-fuchsia-400/30 dark:ring-fuchsia-600/30',
badgeBg: 'bg-fuchsia-400/15 dark:bg-fuchsia-600/20',
badgeText: 'text-fuchsia-700 dark:text-fuchsia-300',
badgeBorder: 'border-fuchsia-400/40 dark:border-fuchsia-600/40',
tickLine: 'bg-fuchsia-400 dark:bg-fuchsia-600',
};
}
// Default to DEV / Development
return {
shortName: 'DEV',
fullName: statusName || 'Development',
dotBg: 'bg-rose-400 dark:bg-rose-600',
dotBorder: 'border-rose-300 dark:border-rose-500',
ringColor: 'ring-rose-400/30 dark:ring-rose-600/30',
badgeBg: 'bg-rose-400/15 dark:bg-rose-600/20',
badgeText: 'text-rose-700 dark:text-rose-300',
badgeBorder: 'border-rose-400/40 dark:border-rose-600/40',
tickLine: 'bg-rose-400 dark:bg-rose-600',
};
}
/**
* Generates the Next 2 Months Milestone roadmap for a client.
* Strictly adheres to the layout & colors of the attached design:
@@ -204,55 +277,55 @@ export function getClientMilestones(client: IClient): Milestone[] {
phase: 'Dev',
dateRange: '01 Oct – 10 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-rose-950/70',
capsuleBorder: 'border-rose-500/80',
capsuleText: 'text-rose-100',
lineColor: 'bg-rose-400 dark:bg-rose-600',
nodeBorderColor: 'border-rose-400 dark:border-rose-600',
},
{
id: 'm2',
phase: 'SIT',
dateRange: '11 Oct – 18 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#853d16]',
capsuleBorder: 'border-[#b45309]',
capsuleText: 'text-white',
lineColor: 'bg-[#b45309]',
nodeBorderColor: 'border-[#b45309]',
capsuleBg: 'bg-orange-950/70',
capsuleBorder: 'border-orange-500/80',
capsuleText: 'text-orange-100',
lineColor: 'bg-orange-400 dark:bg-orange-600',
nodeBorderColor: 'border-orange-400 dark:border-orange-600',
},
{
id: 'm3',
phase: 'UAT',
dateRange: '19 Oct – 25 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#14532d]',
capsuleBorder: 'border-[#15803d]',
capsuleText: 'text-white',
lineColor: 'bg-[#15803d]',
nodeBorderColor: 'border-[#15803d]',
capsuleBg: 'bg-yellow-950/70',
capsuleBorder: 'border-yellow-500/80',
capsuleText: 'text-yellow-100',
lineColor: 'bg-yellow-400 dark:bg-yellow-500',
nodeBorderColor: 'border-yellow-400 dark:border-yellow-500',
},
{
id: 'm4',
phase: 'PTR',
dateRange: '26 Oct – 05 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#0369a1]',
capsuleBorder: 'border-[#0284c7]',
capsuleText: 'text-white',
lineColor: 'bg-[#0284c7]',
nodeBorderColor: 'border-[#0284c7]',
capsuleBg: 'bg-emerald-950/70',
capsuleBorder: 'border-emerald-500/80',
capsuleText: 'text-emerald-100',
lineColor: 'bg-emerald-400 dark:bg-emerald-600',
nodeBorderColor: 'border-emerald-400 dark:border-emerald-600',
},
{
id: 'm5',
phase: 'Live',
dateRange: '06 Nov – 15 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-cyan-950/70',
capsuleBorder: 'border-cyan-500/80',
capsuleText: 'text-cyan-100',
lineColor: 'bg-cyan-400 dark:bg-cyan-600',
nodeBorderColor: 'border-cyan-400 dark:border-cyan-600',
},
];
} else if (seed === 1) {
@@ -262,55 +335,55 @@ export function getClientMilestones(client: IClient): Milestone[] {
phase: 'Dev',
dateRange: '01 Oct – 08 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-rose-950/70',
capsuleBorder: 'border-rose-500/80',
capsuleText: 'text-rose-100',
lineColor: 'bg-rose-400 dark:bg-rose-600',
nodeBorderColor: 'border-rose-400 dark:border-rose-600',
},
{
id: 'm2',
phase: 'SIT',
dateRange: '09 Oct – 17 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#853d16]',
capsuleBorder: 'border-[#b45309]',
capsuleText: 'text-white',
lineColor: 'bg-[#b45309]',
nodeBorderColor: 'border-[#b45309]',
capsuleBg: 'bg-orange-950/70',
capsuleBorder: 'border-orange-500/80',
capsuleText: 'text-orange-100',
lineColor: 'bg-orange-400 dark:bg-orange-600',
nodeBorderColor: 'border-orange-400 dark:border-orange-600',
},
{
id: 'm3',
phase: 'UAT',
dateRange: '18 Oct – 24 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#14532d]',
capsuleBorder: 'border-[#15803d]',
capsuleText: 'text-white',
lineColor: 'bg-[#15803d]',
nodeBorderColor: 'border-[#15803d]',
capsuleBg: 'bg-yellow-950/70',
capsuleBorder: 'border-yellow-500/80',
capsuleText: 'text-yellow-100',
lineColor: 'bg-yellow-400 dark:bg-yellow-500',
nodeBorderColor: 'border-yellow-400 dark:border-yellow-500',
},
{
id: 'm4',
phase: 'PTR',
dateRange: '25 Oct – 08 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#0369a1]',
capsuleBorder: 'border-[#0284c7]',
capsuleText: 'text-white',
lineColor: 'bg-[#0284c7]',
nodeBorderColor: 'border-[#0284c7]',
capsuleBg: 'bg-emerald-950/70',
capsuleBorder: 'border-emerald-500/80',
capsuleText: 'text-emerald-100',
lineColor: 'bg-emerald-400 dark:bg-emerald-600',
nodeBorderColor: 'border-emerald-400 dark:border-emerald-600',
},
{
id: 'm5',
phase: 'Live',
dateRange: '09 Nov – 20 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-cyan-950/70',
capsuleBorder: 'border-cyan-500/80',
capsuleText: 'text-cyan-100',
lineColor: 'bg-cyan-400 dark:bg-cyan-600',
nodeBorderColor: 'border-cyan-400 dark:border-cyan-600',
},
];
} else {
@@ -320,55 +393,55 @@ export function getClientMilestones(client: IClient): Milestone[] {
phase: 'Dev',
dateRange: '02 Oct – 09 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-rose-950/70',
capsuleBorder: 'border-rose-500/80',
capsuleText: 'text-rose-100',
lineColor: 'bg-rose-400 dark:bg-rose-600',
nodeBorderColor: 'border-rose-400 dark:border-rose-600',
},
{
id: 'm2',
phase: 'SIT',
dateRange: '10 Oct – 18 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#853d16]',
capsuleBorder: 'border-[#b45309]',
capsuleText: 'text-white',
lineColor: 'bg-[#b45309]',
nodeBorderColor: 'border-[#b45309]',
capsuleBg: 'bg-orange-950/70',
capsuleBorder: 'border-orange-500/80',
capsuleText: 'text-orange-100',
lineColor: 'bg-orange-400 dark:bg-orange-600',
nodeBorderColor: 'border-orange-400 dark:border-orange-600',
},
{
id: 'm3',
phase: 'UAT',
dateRange: '19 Oct – 27 Oct',
month: 'Oct 2026',
capsuleBg: 'bg-[#14532d]',
capsuleBorder: 'border-[#15803d]',
capsuleText: 'text-white',
lineColor: 'bg-[#15803d]',
nodeBorderColor: 'border-[#15803d]',
capsuleBg: 'bg-yellow-950/70',
capsuleBorder: 'border-yellow-500/80',
capsuleText: 'text-yellow-100',
lineColor: 'bg-yellow-400 dark:bg-yellow-500',
nodeBorderColor: 'border-yellow-400 dark:border-yellow-500',
},
{
id: 'm4',
phase: 'PTR',
dateRange: '28 Oct – 10 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#0369a1]',
capsuleBorder: 'border-[#0284c7]',
capsuleText: 'text-white',
lineColor: 'bg-[#0284c7]',
nodeBorderColor: 'border-[#0284c7]',
capsuleBg: 'bg-emerald-950/70',
capsuleBorder: 'border-emerald-500/80',
capsuleText: 'text-emerald-100',
lineColor: 'bg-emerald-400 dark:bg-emerald-600',
nodeBorderColor: 'border-emerald-400 dark:border-emerald-600',
},
{
id: 'm5',
phase: 'Live',
dateRange: '11 Nov – 22 Nov',
month: 'Nov 2026',
capsuleBg: 'bg-[#7a1c28]',
capsuleBorder: 'border-[#9e2233]',
capsuleText: 'text-white',
lineColor: 'bg-[#9e2233]',
nodeBorderColor: 'border-[#9e2233]',
capsuleBg: 'bg-cyan-950/70',
capsuleBorder: 'border-cyan-500/80',
capsuleText: 'text-cyan-100',
lineColor: 'bg-cyan-400 dark:bg-cyan-600',
nodeBorderColor: 'border-cyan-400 dark:border-cyan-600',
},
];
}