diff --git a/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx b/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx index e1bbc97..1c27d49 100644 --- a/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx +++ b/app/(dashboard)/task/component/client/ClientMilestoneTimeline.tsx @@ -23,6 +23,16 @@ interface GroupedMilestone { items: IClientMilestone[]; } +interface GradientSegment { + fromPercent: number; + toPercent: number; + fromHex: string; + toHex: string; +} + +// Starting color for active milestone line: Merah rose (Development) +const START_LINE_HEX = '#f43f5e'; + export default function ClientMilestoneTimeline({ client, variant = 'list' }: ClientMilestoneTimelineProps) { const today = dayjs().startOf('day'); const maxDate = today.add(2, 'month').startOf('day'); @@ -60,6 +70,34 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl const groups = Object.values(groupsMap).sort((a, b) => a.diffDays - b.diffDays); + // Compute sequential line gradient segments: + // Starts at Hari Ini (0%, Merah Rose) -> Agenda 1 -> Agenda 2 -> ... -> Agenda N + const gradientSegments: GradientSegment[] = []; + + if (groups.length > 0) { + let currentPercent = 0; + let currentHex = START_LINE_HEX; + + for (let i = 0; i < groups.length; i++) { + const group = groups[i]; + const targetPercent = group.percent; + const targetMeta = resolveTechnicalStatusMeta(group.items[0]?.project_assignment_status?.name); + const targetHex = targetMeta.hexColor; + + if (targetPercent > currentPercent) { + gradientSegments.push({ + fromPercent: currentPercent, + toPercent: targetPercent, + fromHex: currentHex, + toHex: targetHex, + }); + } + + currentPercent = targetPercent; + currentHex = targetHex; + } + } + // 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'); @@ -82,7 +120,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl } const isGrid = variant === 'grid'; - console.log(groups) + const hasAgendas = groups.length > 0; return (