diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx index ef3fe3b..994a9d4 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx @@ -151,14 +151,49 @@ export function ProjectMilestoneTimeline({ const techName = technicalStatus?.name?.toLowerCase() || ''; const techId = technicalStatus?.id; - let techRank = 0; - if (techId === 6 || techName.includes('dev')) techRank = 1; - else if (techId === 7 || techName.includes('sit')) techRank = 2; - else if (techId === 8 || techName.includes('uat')) techRank = 3; - else if (techId === 9 || techName.includes('ptr')) techRank = 4; - else if (techId === 10 || techName.includes('go-live') || techName.includes('live')) techRank = 5; - else if (techId === 11 || techName.includes('bast') || techName.includes('handover')) techRank = 6; - else if (techId === 12 || techName.includes('warranty')) techRank = 7; + let baseTechRank = 0; + if (techId === 6 || techName.includes('dev')) baseTechRank = 1; + else if (techId === 7 || techName.includes('sit')) baseTechRank = 2; + else if (techId === 8 || techName.includes('uat')) baseTechRank = 3; + else if (techId === 9 || techName.includes('ptr')) baseTechRank = 4; + else if (techId === 10 || techName.includes('go-live') || techName.includes('live')) baseTechRank = 5; + else if (techId === 11 || techName.includes('bast') || techName.includes('handover')) baseTechRank = 6; + else if (techId === 12 || techName.includes('warranty')) baseTechRank = 7; + + // Check if statusDetails has assigned dates to ensure scheduled future dates don't prematurely activate stages + const techRank = useMemo(() => { + const detailsWithDates = statusDetails.filter(d => { + const { start, end } = getDetailDateRange(d); + return Boolean(start || end); + }); + + if (detailsWithDates.length > 0) { + let maxStarted = 0; + detailsWithDates.forEach(d => { + const { start } = getDetailDateRange(d); + if (start && dayjs(start).isValid()) { + if (todayVal >= dayjs(start).startOf('day').valueOf()) { + const name = d.project_assignment_status?.name?.toLowerCase() || ''; + const id = d.project_assignment_status?.id; + let r = 0; + if (id === 6 || name.includes('dev')) r = 1; + else if (id === 7 || name.includes('sit')) r = 2; + else if (id === 8 || name.includes('uat')) r = 3; + else if (id === 9 || name.includes('ptr')) r = 4; + else if (id === 10 || name.includes('go-live') || name.includes('live')) r = 5; + else if (id === 11 || name.includes('bast') || name.includes('handover')) r = 6; + else if (id === 12 || name.includes('warranty')) r = 7; + if (r > maxStarted) maxStarted = r; + } + } + }); + + if (maxStarted > 0) return maxStarted; + return 1; // default to stage 1 (Dev) + } + + return baseTechRank; + }, [statusDetails, todayVal, baseTechRank]); // Checkpoint dates const sitEndTime = getDetailEndTime(sitDetail); diff --git a/app/(dashboard)/task/component/client/ClientList.tsx b/app/(dashboard)/task/component/client/ClientList.tsx index a093efd..d7069c3 100644 --- a/app/(dashboard)/task/component/client/ClientList.tsx +++ b/app/(dashboard)/task/component/client/ClientList.tsx @@ -47,7 +47,7 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp transition={{ duration: 0.25, delay: index * 0.04 }} className="w-full" > - + {/* Top Section: 3-column layout (Identity | Status Breakdown | Quick Stats) */}
{/* Left Column: Client Identity & Team (col-span-3) */} diff --git a/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx b/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx index 1c27d49..54eec05 100644 --- a/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx +++ b/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx @@ -150,13 +150,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl {/* Timeline Viewport Container with group/rail for sibling hover coordination */}
-
+
{/* Continuous 2-Month Horizontal Rail */}
{/* Gradient Segments connecting Hari Ini -> Agenda 1 -> Agenda 2 -> ... */} @@ -196,8 +190,8 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl className="absolute -top-1 -translate-x-1/2 flex flex-col items-center pointer-events-none select-none z-0" style={{ left: `${tick.percent}%` }} > -
- +
+ {tick.label}
@@ -206,7 +200,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl {/* If no milestones in range, show gentle notice */} {!hasAgendas && (
- + No upcoming milestones in the next 2 months
@@ -229,8 +223,8 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl // When any node is hovered, soften non-hovered siblings "group-hover/rail:opacity-40 group-hover/rail:scale-95", // Actively hovered node is fully opaque, prominent, and scaled up - "hover:!opacity-100 hover:!scale-115", - "focus-within:!opacity-100 focus-within:!scale-115" + "hover:opacity-100!", + "focus-within:opacity-100! " )} style={{ left: `${group.percent}%` }} > @@ -255,8 +249,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl "bg-transparent border border-transparent", // Hover state: solid high-contrast backdrop card with shadow // Completely covers any adjacent date text underneath it - "group-hover/node:bg-card/95 dark:group-hover/node:bg-zinc-900/95", - "group-hover/node:shadow-xl group-hover/node:shadow-black/20 dark:group-hover/node:shadow-black/70", + "group-hover/node:bg-card/95 dark:group-hover/node:bg-zinc-900/10", "group-hover/node:backdrop-blur-md" )} aria-label={`Milestones on ${group.date.format('DD MMM YYYY')}`} @@ -267,7 +260,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl className={cn( "relative size-4 sm:size-4.5 rounded-full p-[1.5px] shadow-sm ring-2 ring-background transition-all duration-200", "group-hover/node:size-5 group-hover/node:ring-4 group-hover/node:ring-amber-500/40 group-hover/node:shadow-md", - "bg-gradient-to-br from-amber-400 via-rose-500 to-violet-600" + "bg-linear-to-br from-amber-400 via-rose-500 to-violet-600" )} title={`${group.items.length} agendas on this date`} > @@ -310,7 +303,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl {/* Date Label strictly underneath */} diff --git a/app/(dashboard)/task/utils/assignment-overview-helpers.ts b/app/(dashboard)/task/utils/assignment-overview-helpers.ts index 0b246f5..798df77 100644 --- a/app/(dashboard)/task/utils/assignment-overview-helpers.ts +++ b/app/(dashboard)/task/utils/assignment-overview-helpers.ts @@ -2,7 +2,7 @@ import dayjs from 'dayjs'; import { IProjectAssignment, StatusDetailDateEntry } from '../type.assignment'; export interface ProgressColorConfig { - name: 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'red'; + name: 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'red' | 'sky' | 'teal'; label: string; hex: string; barColor: string; @@ -15,6 +15,66 @@ export interface ProgressColorConfig { } export const COLOR_SPECTRUM: Record = { + sky: { + name: 'sky', + label: 'Completed', + hex: '#0ea5e9', + barColor: 'bg-sky-500', + textColor: 'text-sky-500 dark:text-sky-400', + glowRing: 'ring-4 ring-sky-500/30 shadow-[0_0_12px_rgba(14,165,233,0.6)]', + activeDot: 'bg-sky-500', + badgeBg: 'bg-sky-500/10 dark:bg-sky-500/20', + badgeText: 'text-sky-600 dark:text-sky-400', + badgeBorder: 'border-sky-500/30', + }, + teal: { + name: 'teal', + label: 'Near Go-live', + hex: '#14b8a6', + barColor: 'bg-teal-500', + textColor: 'text-teal-500 dark:text-teal-400', + glowRing: 'ring-4 ring-teal-500/30 shadow-[0_0_12px_rgba(20,184,166,0.6)]', + activeDot: 'bg-teal-500', + badgeBg: 'bg-teal-500/10 dark:bg-teal-500/20', + badgeText: 'text-teal-600 dark:text-teal-400', + badgeBorder: 'border-teal-500/30', + }, + yellow: { + name: 'yellow', + label: 'At Risk', + hex: '#eab308', + barColor: 'bg-yellow-500', + textColor: 'text-yellow-500 dark:text-yellow-400', + glowRing: 'ring-4 ring-yellow-500/30 shadow-[0_0_12px_rgba(234,179,8,0.6)]', + activeDot: 'bg-yellow-500', + badgeBg: 'bg-yellow-500/15 dark:bg-yellow-500/20', + badgeText: 'text-yellow-700 dark:text-yellow-400', + badgeBorder: 'border-yellow-500/30', + }, + red: { + name: 'red', + label: 'Critical / Off Track', + hex: '#ef4444', + barColor: 'bg-red-500', + textColor: 'text-red-500 dark:text-red-400', + glowRing: 'ring-4 ring-red-500/30 shadow-[0_0_12px_rgba(239,68,68,0.6)]', + activeDot: 'bg-red-500', + badgeBg: 'bg-red-500/10 dark:bg-red-500/20', + badgeText: 'text-red-600 dark:text-red-400', + badgeBorder: 'border-red-500/30', + }, + green: { + name: 'green', + label: 'On Track', + hex: '#10b981', + barColor: 'bg-emerald-500', + textColor: 'text-emerald-500 dark:text-emerald-400', + glowRing: 'ring-4 ring-emerald-500/30 shadow-[0_0_12px_rgba(16,185,129,0.6)]', + activeDot: 'bg-emerald-500', + badgeBg: 'bg-emerald-500/10 dark:bg-emerald-500/20', + badgeText: 'text-emerald-600 dark:text-emerald-400', + badgeBorder: 'border-emerald-500/30', + }, orange: { name: 'orange', label: 'Awal', @@ -27,30 +87,6 @@ export const COLOR_SPECTRUM: Record = { badgeText: 'text-[#ea512c]', badgeBorder: 'border-[#ea512c]/30', }, - yellow: { - name: 'yellow', - label: 'Menuju Pertengahan', - hex: '#eab308', - barColor: 'bg-[#eab308]', - textColor: 'text-[#eab308]', - glowRing: 'ring-4 ring-[#eab308]/30 shadow-[0_0_12px_rgba(234,179,8,0.6)]', - activeDot: 'bg-[#eab308]', - badgeBg: 'bg-[#eab308]/15', - badgeText: 'text-[#eab308]', - badgeBorder: 'border-[#eab308]/30', - }, - green: { - name: 'green', - label: 'Pertengahan', - hex: '#10b981', - barColor: 'bg-[#10b981]', - textColor: 'text-[#10b981]', - glowRing: 'ring-4 ring-[#10b981]/30 shadow-[0_0_12px_rgba(16,185,129,0.6)]', - activeDot: 'bg-[#10b981]', - badgeBg: 'bg-[#10b981]/15', - badgeText: 'text-[#10b981]', - badgeBorder: 'border-[#10b981]/30', - }, blue: { name: 'blue', label: 'Lanjut', @@ -75,18 +111,6 @@ export const COLOR_SPECTRUM: Record = { badgeText: 'text-[#a855f7]', badgeBorder: 'border-[#a855f7]/30', }, - red: { - name: 'red', - label: 'Critical / Off Track', - hex: '#f43f5e', - barColor: 'bg-rose-500', - textColor: 'text-rose-500 dark:text-rose-400', - glowRing: 'ring-4 ring-rose-500/30 shadow-[0_0_12px_rgba(244,63,94,0.6)]', - activeDot: 'bg-rose-500', - badgeBg: 'bg-rose-500/15 dark:bg-rose-500/20', - badgeText: 'text-rose-600 dark:text-rose-400', - badgeBorder: 'border-rose-500/30', - }, }; export interface AssignmentOverview { @@ -192,7 +216,7 @@ export const isDateTodayOrInRange = (startDate?: string | null, endDate?: string if (start && end) { return (today.isSame(start, 'day') || today.isAfter(start)) && - (today.isSame(end, 'day') || today.isBefore(end)); + (today.isSame(end, 'day') || today.isBefore(end)); } if (start && !end) { return today.isSame(start, 'day') || today.isAfter(start); @@ -221,19 +245,95 @@ export function getTechnicalStageRank(rawName?: string | null): number { return 0; } +/** + * Checks if a status detail phase has started based on its scheduled dates. + * A phase has started if today is on or after its start_date (or end_date if no start_date). + */ +export const isDetailStarted = (d: any): boolean => { + if (!d) return false; + const entries = getStatusDetailDateEntries(d); + if (entries.length === 0) return false; + const today = dayjs().startOf('day'); + return entries.some(entry => { + const target = entry.start_date || entry.end_date; + if (!target) return false; + const dObj = dayjs(target); + return dObj.isValid() && (today.isSame(dObj.startOf('day')) || today.isAfter(dObj.startOf('day'))); + }); +}; + /** * 1. Derives project status: * Priority: - * 1. project_assignment_technical_status.name if present - * 2. project_assignment_status_detail that matches today's date - * 3. Fallback: latest detail or project_assignment_status.name or 'Active' + * 1. project_assignment_status_detail with assigned dates: + * a. Phase matching today's date (isDateTodayOrInRange) + * b. Highest phase that has started (start_date <= today) + * c. If none has started yet (all in future), first scheduled phase (Dev) + * 2. Fallback when NO details have dates: + * a. project_assignment_technical_status.name + * b. project_assignment_status.name */ export function resolveProjectStatus(assignment: IProjectAssignment, indexFallback = 0): { statusName: string; isFromDetail: boolean; phaseIndex: number; } { - // 1. Technical status priority + const details = assignment.project_assignment_status_detail || []; + const detailsWithDates = details.filter(hasAssignedDates); + + // 1. If details have dates assigned, prioritize date-based progression: + if (detailsWithDates.length > 0) { + // A. Check if any detail matches today's date + let activeDetail: any = null; + + for (let i = 0; i < detailsWithDates.length; i++) { + const d = detailsWithDates[i]; + const entries = getStatusDetailDateEntries(d); + const matchesToday = entries.some(entry => isDateTodayOrInRange(entry.start_date, entry.end_date)); + if (matchesToday) { + activeDetail = d; + break; + } + } + + if (activeDetail?.project_assignment_status?.name) { + const rawName = activeDetail.project_assignment_status.name; + return { + statusName: formatShortPhaseName(rawName), + isFromDetail: true, + phaseIndex: mapStatusNameToPhaseIndex(rawName), + }; + } + + // B. If none matches today, find the highest rank stage that has actually started (start_date <= today) + const startedDetails = detailsWithDates.filter(isDetailStarted); + if (startedDetails.length > 0) { + startedDetails.sort((a, b) => { + const rankA = getTechnicalStageRank(a.project_assignment_status?.name); + const rankB = getTechnicalStageRank(b.project_assignment_status?.name); + return rankA - rankB; + }); + const latestStarted = startedDetails[startedDetails.length - 1]; + const rawName = latestStarted.project_assignment_status?.name || 'Development'; + return { + statusName: formatShortPhaseName(rawName), + isFromDetail: true, + phaseIndex: mapStatusNameToPhaseIndex(rawName), + }; + } + + // C. If NO detail has started yet (all scheduled in the future): + // Pick the earliest scheduled stage (e.g. Development) + const firstStage = detailsWithDates[0]; + const rawName = firstStage?.project_assignment_status?.name || 'Development'; + return { + statusName: formatShortPhaseName(rawName), + isFromDetail: true, + phaseIndex: mapStatusNameToPhaseIndex(rawName), + }; + } + + // 2. Fallback when NO details have dates assigned: if (assignment.project_assignment_technical_status?.name) { const rawName = assignment.project_assignment_technical_status.name; return { @@ -243,99 +343,86 @@ export function resolveProjectStatus(assignment: IProjectAssignment, indexFallba }; } - const details = assignment.project_assignment_status_detail || []; - - // Filter only entries that actually have dates assigned - const detailsWithDates = details.filter(hasAssignedDates); - - // 2. Check if any detail matches today's date - let activeDetail: any = null; - - for (let i = 0; i < detailsWithDates.length; i++) { - const d = detailsWithDates[i]; - const entries = getStatusDetailDateEntries(d); - const matchesToday = entries.some(entry => isDateTodayOrInRange(entry.start_date, entry.end_date)); - if (matchesToday) { - activeDetail = d; - break; - } - } - - if (activeDetail?.project_assignment_status?.name) { - const rawName = activeDetail.project_assignment_status.name; + if (assignment.project_assignment_status?.name) { + const name = assignment.project_assignment_status.name; return { - statusName: formatShortPhaseName(rawName), - isFromDetail: true, - phaseIndex: mapStatusNameToPhaseIndex(rawName), - }; - } - - // 3. Fallback: if NO detail has dates assigned -> fallback directly to project_assignment_status.name - if (detailsWithDates.length === 0) { - if (assignment.project_assignment_status?.name) { - const name = assignment.project_assignment_status.name; - return { - statusName: name, - isFromDetail: false, - phaseIndex: mapStatusNameToPhaseIndex(name), - }; - } - return { - statusName: 'Not Started', + statusName: name, isFromDetail: false, - phaseIndex: 0, + phaseIndex: mapStatusNameToPhaseIndex(name), }; } - // If there were details with dates, but none matched today, pick the latest stage with dates - const chosen = detailsWithDates[detailsWithDates.length - 1]; - const rawName = chosen?.project_assignment_status?.name || assignment.project_assignment_status?.name || 'Active'; - return { - statusName: formatShortPhaseName(rawName), - isFromDetail: true, - phaseIndex: mapStatusNameToPhaseIndex(rawName), + statusName: 'Not Started', + isFromDetail: false, + phaseIndex: 0, }; } /** - * Resolves technical status from either project_assignment_technical_status.name - * OR the highest reached stage in project_assignment_status_detail (with assigned dates). + * Resolves technical status from either project_assignment_status_detail (with assigned dates that have started) + * OR fallback to project_assignment_technical_status.name when no dates are scheduled. */ export function resolveTechnicalStatus(assignment: IProjectAssignment): { technicalStatusName: string | null; hasTechnicalStatus: boolean; technicalRank: number; } { - // 1. Check project_assignment_technical_status + const details = assignment.project_assignment_status_detail || []; + const detailsWithDates = details.filter(hasAssignedDates); + + // 1. If details have assigned dates, technical rank is strictly derived from stages that have started: + if (detailsWithDates.length > 0) { + let maxStartedRank = 0; + let maxStartedName: string | null = null; + + detailsWithDates.forEach(d => { + if (isDetailStarted(d) && d.project_assignment_status?.name) { + const r = getTechnicalStageRank(d.project_assignment_status.name); + if (r > maxStartedRank) { + maxStartedRank = r; + maxStartedName = d.project_assignment_status.name; + } + } + }); + + // Also check if any stage matches today directly + detailsWithDates.forEach(d => { + const entries = getStatusDetailDateEntries(d); + const matchesToday = entries.some(entry => isDateTodayOrInRange(entry.start_date, entry.end_date)); + if (matchesToday && d.project_assignment_status?.name) { + const r = getTechnicalStageRank(d.project_assignment_status.name); + if (r > maxStartedRank) { + maxStartedRank = r; + maxStartedName = d.project_assignment_status.name; + } + } + }); + + if (maxStartedRank > 0) { + return { + technicalStatusName: maxStartedName, + hasTechnicalStatus: true, + technicalRank: maxStartedRank, + }; + } + + // None has started yet (all dates are future) + return { + technicalStatusName: detailsWithDates[0]?.project_assignment_status?.name || null, + hasTechnicalStatus: false, + technicalRank: 0, + }; + } + + // 2. Fallback when NO details have dates: use project_assignment_technical_status.name const techName = assignment.project_assignment_technical_status?.name || null; const rankTech = techName ? getTechnicalStageRank(techName) : 0; - // 2. Check project_assignment_status_detail for dated entries - const details = assignment.project_assignment_status_detail || []; - let maxDetailRank = 0; - let maxDetailName: string | null = null; - - details.forEach(d => { - if (hasAssignedDates(d) && d.project_assignment_status?.name) { - const r = getTechnicalStageRank(d.project_assignment_status.name); - if (r > maxDetailRank) { - maxDetailRank = r; - maxDetailName = d.project_assignment_status.name; - } - } - }); - - const technicalRank = Math.max(rankTech, maxDetailRank); - const hasTechnicalStatus = technicalRank > 0; - const technicalStatusName = (rankTech >= maxDetailRank && techName) - ? techName - : (maxDetailName || techName || null); - return { - technicalStatusName, - hasTechnicalStatus, - technicalRank, + technicalStatusName: techName, + hasTechnicalStatus: rankTech > 0, + technicalRank: rankTech, }; } @@ -362,42 +449,48 @@ function mapStatusNameToPhaseIndex(name: string): number { } /** - * 2. Progress Color Logic: - * Warna fill progress bar dan stepper rail tetap dipertahankan sesuai logic gradasi 5 spektrum: - * - 0% – 18%: Mengarah ke Oranye (#ea512c) - * - 18% – 35%: Kuning (#eab308) - * - 35% – 65%: Hijau (#10b981) (mencakup titik pertengahan ~50%) - * - 65% – 88%: Biru (#3b82f6) - * - >= 88% atau mendekati batas akhir deadline (<= 14 hari): Ungu (#a855f7) + * 2. Progress / Milestone Color Logic: + * Warna milestone dan progress disesuaikan dengan 5 rules: + * - Complete (Sky Blue) + * - Near Go-live (Warna Teal) + * - At Risk (Warna Kuning) + * - Off Track / Critical (Warna Merah) + * - On Track (Warna Hijau) */ export function resolveProgressColor( - progressPercent: number, - isNearEndDate: boolean, - isPastEndDate: boolean, + healthStatusOrProgress: 'On Track' | 'At Risk' | 'Near Go-live' | 'Completed' | 'Critical' | 'Off Track' | number, + isNearEndDate?: boolean, + isPastEndDate?: boolean, _isCriticalOffTrack?: boolean ): ProgressColorConfig { - // >= 88% atau mendekati batas akhir deadline (<= 14 hari) atau lewat deadline -> Ungu (#a855f7) - if (isPastEndDate || isNearEndDate || progressPercent >= 88) { - return COLOR_SPECTRUM.purple; + if (typeof healthStatusOrProgress === 'string') { + switch (healthStatusOrProgress) { + case 'Completed': + return COLOR_SPECTRUM.sky; + case 'Near Go-live': + return COLOR_SPECTRUM.teal; + case 'At Risk': + return COLOR_SPECTRUM.yellow; + case 'Critical': + case 'Off Track': + return COLOR_SPECTRUM.red; + case 'On Track': + default: + return COLOR_SPECTRUM.green; + } } - // 65% – 88%: Biru (#3b82f6) - if (progressPercent > 65) { - return COLOR_SPECTRUM.blue; + // Fallback if called with progressPercent number + if (isPastEndDate || _isCriticalOffTrack) { + return COLOR_SPECTRUM.red; } - - // 35% – 65%: Hijau (#10b981) (mencakup titik pertengahan ~50%) - if (progressPercent >= 35) { - return COLOR_SPECTRUM.green; + if (isNearEndDate) { + return COLOR_SPECTRUM.teal; } - - // 18% – 35%: Kuning (#eab308) - if (progressPercent >= 18) { + if (healthStatusOrProgress > 75) { return COLOR_SPECTRUM.yellow; } - - // 0% – 18%: Mengarah ke Oranye (#ea512c) - return COLOR_SPECTRUM.orange; + return COLOR_SPECTRUM.green; } /** @@ -468,8 +561,7 @@ export function resolveDeliveryHealth( }; } - // Off Track / Critical (Warna Merah) => sama atau lewat deadline and belum sampai ke Go-Live (rank < 5) - // Perhatian: Walaupun progress hari sudah 100%, jika belum Go-Live maka tetap Critical / Off Track! + // Off Track / Critical (Warna Merah) => sama atau lewat deadline and belum sampai ke Go-Live status (rank < 5) const label = (!hasTechnicalStatus || technicalRank === 0) ? 'Off Track' : 'Critical'; return { healthStatus: label, @@ -479,9 +571,9 @@ export function resolveDeliveryHealth( }; } - // KONDISI 2: Belum lewat deadline (atau tidak ada endDate) + // KONDISI 2: Belum lewat deadline (masih dalam rentang end of date) - // 1. Sudah sampai ke Go-Live sebelum deadline -> Complete (Sky Blue) + // A. Sudah sampai ke Go-Live sebelum deadline -> Complete (Sky Blue) if (technicalRank >= 5) { return { healthStatus: 'Completed', @@ -491,9 +583,12 @@ export function resolveDeliveryHealth( }; } - // 2. Near Go-live (Warna Teal) => Technical status sudah lewat PTR (rank >= 4), tanggal hari ini sudah lewat dari tanggal PTR tapi masih dalam rentang end of date, dan technical status belum sampai ke Go-Live (rank < 5) - const isPastPtrDate = typeof ptrEndDate === 'number' ? now >= ptrEndDate : (technicalRank >= 4 && progressPercent >= 75); - if (technicalRank >= 4 && isPastPtrDate) { + // B. Near Go-live (Warna Teal) => technical status sudah lewat PTR dan tanggal hari ini sudah lewat dari tanggal PTR tapi masih dalam rentang end of date dan status belum sampai ke Go-Live + const isPastPtrDate = typeof ptrEndDate === 'number' + ? now > ptrEndDate + : (technicalRank >= 4 && progressPercent >= 75); + + if (technicalRank >= 4 && isPastPtrDate && technicalRank < 5) { return { healthStatus: 'Near Go-live', healthBadgeClass: 'bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/30', @@ -502,7 +597,7 @@ export function resolveDeliveryHealth( }; } - // 3. At Risk (Warna Kuning) => progress lewat dari 75% dan belum sampai ke PTR (rank < 4) + // C. At Risk (Warna Kuning) => progress lewat dari 75% dan namun belum sampai ke PTR (rank < 4) if (progressPercent > 75 && technicalRank < 4) { return { healthStatus: 'At Risk', @@ -512,7 +607,7 @@ export function resolveDeliveryHealth( }; } - // 4. On Track (Warna Hijau) => Belum lewat deadline dan progres sejalan dengan target + // D. On Track (Warna Hijau) => Belum lewat deadline dan progres sejalan dengan target (progress <= 75%, atau sudah sampai ke PTR) return { healthStatus: 'On Track', healthBadgeClass: 'bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30', @@ -580,8 +675,8 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num ptrEndDate ); - // 3. Resolve Progress Color (Orange -> Kuning -> Hijau -> Biru -> Ungu) - const progressColor = resolveProgressColor(progressPercent, isNearEndDate, isPastEndDate, isCritical); + // 3. Resolve Progress / Milestone Color (Complete = Sky Blue, Near Go-live = Teal, At Risk = Kuning, Off Track/Critical = Merah, On Track = Hijau) + const progressColor = resolveProgressColor(healthStatus); // 4. Team members extraction strictly from project_assignment_work_order_detail const rawTeam = Array.isArray(assignment.project_assignment_work_order_detail) @@ -619,7 +714,11 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num } else { const remDays = Math.max(1, totalDays - elapsedDays); remainingText = totalDays > 0 ? `${remDays} days remaining` : 'Schedule pending'; - nextMilestoneText = phaseIndex === 0 ? 'Next: Feature Development' : 'Next: SIT Testing'; + if (phaseIndex === 0) nextMilestoneText = 'Next: SIT Testing'; + else if (phaseIndex === 1) nextMilestoneText = 'Next: UAT Testing'; + else if (phaseIndex === 2) nextMilestoneText = 'Next: Production Trial Run'; + else if (phaseIndex === 3) nextMilestoneText = 'Next: Go-Live'; + else nextMilestoneText = 'Next: Project Handover'; } const updatedAgoText = formatRelativeTime(assignment.created_at || startDate);