mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Handle unstarted assignment phases
Represent pending assignments with no active phase, show Development as the next milestone, and align the grid and list steppers' rails with their stage dots.
This commit is contained in:
@@ -26,37 +26,48 @@ import { END_USER_FALLBACK_IMAGE } from '../../types';
|
||||
const STEPPER_STAGES = ['Dev', 'SIT', 'UAT', 'PTR', 'Live'] as const;
|
||||
|
||||
function CompactPhaseStepper({ phaseIndex, progressColor }: { phaseIndex: number; progressColor: ProgressColorConfig }) {
|
||||
const activeLineWidth = phaseIndex <= 0 ? 0 : Math.min(80, Math.max(0, (phaseIndex / 4) * 80));
|
||||
|
||||
return (
|
||||
<div className="relative pt-2 pb-0.5 w-full">
|
||||
{/* Background Rail Line */}
|
||||
<div className="absolute top-3.5 left-2 right-2 h-0.5 bg-muted dark:bg-zinc-800" />
|
||||
{/* Horizontal Rail Lines Container (Vertically centered with h-4 dot slot) */}
|
||||
<div className="absolute top-2 left-0 right-0 h-4 flex items-center pointer-events-none">
|
||||
{/* Background Rail Line (Runs strictly from Dev center 10% to Live center 90%) */}
|
||||
<div
|
||||
className="h-0.5 bg-muted dark:bg-zinc-800 absolute"
|
||||
style={{ left: '10%', width: '80%' }}
|
||||
/>
|
||||
|
||||
{/* Active Colored Fill Line */}
|
||||
<div
|
||||
className={`absolute top-3.5 left-2 h-0.5 ${progressColor.barColor} transition-all duration-300`}
|
||||
style={{ width: `${Math.min(100, Math.max(0, (phaseIndex / 4) * 100))}%` }}
|
||||
/>
|
||||
{/* Active Colored Fill Line */}
|
||||
<div
|
||||
className={`h-0.5 ${progressColor.barColor} transition-all duration-300 absolute`}
|
||||
style={{ left: '10%', width: `${activeLineWidth}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 5 Milestone Stage Nodes */}
|
||||
<div className="relative flex items-center justify-between">
|
||||
<div className="relative grid grid-cols-5 w-full">
|
||||
{STEPPER_STAGES.map((stage, i) => {
|
||||
const isCompleted = i < phaseIndex;
|
||||
const isActive = i === phaseIndex;
|
||||
const isCompleted = phaseIndex >= 0 && i < phaseIndex;
|
||||
const isActive = phaseIndex >= 0 && i === phaseIndex;
|
||||
|
||||
return (
|
||||
<div key={stage} className="flex flex-col items-center gap-1.5 z-10">
|
||||
{isActive ? (
|
||||
<div className={`w-3.5 h-3.5 rounded-full flex items-center justify-center ${progressColor.glowRing} ${progressColor.activeDot} transition-transform`}>
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-white shadow-xs" />
|
||||
</div>
|
||||
) : isCompleted ? (
|
||||
<div className={`w-2.5 h-2.5 rounded-full ${progressColor.barColor} transition-colors`} />
|
||||
) : (
|
||||
<div className="w-2 h-2 rounded-full bg-muted-foreground/30 dark:bg-zinc-700 transition-colors" />
|
||||
)}
|
||||
{/* Dot container with fixed h-4 w-4 ensuring vertical center matches the rail line */}
|
||||
<div className="h-4 w-4 flex items-center justify-center">
|
||||
{isActive ? (
|
||||
<div className={`w-3.5 h-3.5 rounded-full flex items-center justify-center ${progressColor.glowRing} ${progressColor.activeDot} transition-transform`}>
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-white shadow-xs" />
|
||||
</div>
|
||||
) : isCompleted ? (
|
||||
<div className={`w-2.5 h-2.5 rounded-full ${progressColor.barColor} transition-colors`} />
|
||||
) : (
|
||||
<div className="w-2 h-2 rounded-full bg-muted-foreground/30 dark:bg-zinc-700 transition-colors" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<span className={cn(
|
||||
"text-[10px] tracking-tight font-medium transition-colors",
|
||||
"text-[10px] tracking-tight font-medium transition-colors text-center truncate max-w-full",
|
||||
isActive
|
||||
? `${progressColor.textColor} font-bold`
|
||||
: isCompleted
|
||||
|
||||
@@ -28,37 +28,48 @@ export { formatAssignmentDate };
|
||||
const STEPPER_STAGES = ['Dev', 'SIT', 'UAT', 'PTR', 'Live'] as const;
|
||||
|
||||
function PhaseStepper({ phaseIndex, progressColor }: { phaseIndex: number; progressColor: ProgressColorConfig }) {
|
||||
const activeLineWidth = phaseIndex <= 0 ? 0 : Math.min(80, Math.max(0, (phaseIndex / 4) * 80));
|
||||
|
||||
return (
|
||||
<div className="relative pt-2 pb-0.5 w-full">
|
||||
{/* Background Rail Line */}
|
||||
<div className="absolute top-3.5 left-2 right-2 h-0.5 bg-muted-foreground/20 dark:bg-zinc-700" />
|
||||
{/* Horizontal Rail Lines Container (Vertically centered with h-4 dot slot) */}
|
||||
<div className="absolute top-2 left-0 right-0 h-4 flex items-center pointer-events-none">
|
||||
{/* Background Rail Line (Runs strictly from Dev center 10% to Live center 90%) */}
|
||||
<div
|
||||
className="h-0.5 bg-muted-foreground/20 dark:bg-zinc-700 absolute"
|
||||
style={{ left: '10%', width: '80%' }}
|
||||
/>
|
||||
|
||||
{/* Active Colored Fill Line */}
|
||||
<div
|
||||
className={`absolute top-3.5 left-2 h-0.5 ${progressColor.barColor} transition-all duration-300`}
|
||||
style={{ width: `${Math.min(100, Math.max(0, (phaseIndex / 4) * 100))}%` }}
|
||||
/>
|
||||
{/* Active Colored Fill Line */}
|
||||
<div
|
||||
className={`h-0.5 ${progressColor.barColor} transition-all duration-300 absolute`}
|
||||
style={{ left: '10%', width: `${activeLineWidth}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 5 Milestone Stage Nodes */}
|
||||
<div className="relative flex items-center justify-between">
|
||||
<div className="relative grid grid-cols-5 w-full">
|
||||
{STEPPER_STAGES.map((stage, i) => {
|
||||
const isCompleted = i < phaseIndex;
|
||||
const isActive = i === phaseIndex;
|
||||
const isCompleted = phaseIndex >= 0 && i < phaseIndex;
|
||||
const isActive = phaseIndex >= 0 && i === phaseIndex;
|
||||
|
||||
return (
|
||||
<div key={stage} className="flex flex-col items-center gap-1.5 z-10">
|
||||
{isActive ? (
|
||||
<div className={`w-3.5 h-3.5 rounded-full flex items-center justify-center ${progressColor.glowRing} ${progressColor.activeDot} transition-transform`}>
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-white shadow-xs" />
|
||||
</div>
|
||||
) : isCompleted ? (
|
||||
<div className={`w-2.5 h-2.5 rounded-full ${progressColor.barColor} transition-colors`} />
|
||||
) : (
|
||||
<div className="w-2 h-2 rounded-full bg-muted-foreground/70 dark:bg-zinc-600 transition-colors" />
|
||||
)}
|
||||
{/* Dot container with fixed h-4 w-4 ensuring vertical center matches the rail line */}
|
||||
<div className="h-4 w-4 flex items-center justify-center">
|
||||
{isActive ? (
|
||||
<div className={`w-3.5 h-3.5 rounded-full flex items-center justify-center ${progressColor.glowRing} ${progressColor.activeDot} transition-transform`}>
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-white shadow-xs" />
|
||||
</div>
|
||||
) : isCompleted ? (
|
||||
<div className={`w-2.5 h-2.5 rounded-full ${progressColor.barColor} transition-colors`} />
|
||||
) : (
|
||||
<div className="w-2 h-2 rounded-full bg-muted-foreground/70 dark:bg-zinc-600 transition-colors" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<span className={cn(
|
||||
"text-[10px] tracking-tight font-medium transition-colors",
|
||||
"text-[10px] tracking-tight font-medium transition-colors text-center truncate max-w-full",
|
||||
isActive
|
||||
? `${progressColor.textColor} font-bold`
|
||||
: isCompleted
|
||||
|
||||
@@ -369,13 +369,13 @@ export function resolveProjectStatus(assignment: IProjectAssignment, indexFallba
|
||||
}
|
||||
|
||||
// C. If NO detail has started yet (all scheduled in the future):
|
||||
// Pick the earliest scheduled stage (e.g. Development)
|
||||
// Development has not started yet
|
||||
const firstStage = detailsWithDates[0];
|
||||
const rawName = firstStage?.project_assignment_status?.name || 'Development';
|
||||
return {
|
||||
statusName: formatShortPhaseName(rawName),
|
||||
isFromDetail: true,
|
||||
phaseIndex: mapStatusNameToPhaseIndex(rawName),
|
||||
phaseIndex: -1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ export function resolveProjectStatus(assignment: IProjectAssignment, indexFallba
|
||||
return {
|
||||
statusName: 'Not Started',
|
||||
isFromDetail: false,
|
||||
phaseIndex: 0,
|
||||
phaseIndex: -1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -484,14 +484,16 @@ function formatShortPhaseName(raw: string): string {
|
||||
return raw;
|
||||
}
|
||||
|
||||
function mapStatusNameToPhaseIndex(name: string): number {
|
||||
const lower = name.toLowerCase();
|
||||
if (lower.includes('development') || lower === 'dev' || lower.includes('not started')) return 0;
|
||||
function mapStatusNameToPhaseIndex(name?: string | null): number {
|
||||
if (!name) return -1;
|
||||
const lower = name.toLowerCase().trim();
|
||||
if (lower.includes('not started') || lower.includes('pending') || lower.includes('unassigned')) return -1;
|
||||
if (lower.includes('development') || lower === 'dev') return 0;
|
||||
if (lower.includes('sit') || lower.includes('integration')) return 1;
|
||||
if (lower.includes('uat') || lower.includes('acceptance')) return 2;
|
||||
if (lower.includes('ptr') || lower.includes('trial')) return 3;
|
||||
if (lower.includes('go-live') || lower.includes('live') || lower.includes('bast') || lower.includes('warranty') || lower.includes('complete')) return 4;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -760,7 +762,8 @@ export function getAssignmentOverview(assignment: IProjectAssignment, index: num
|
||||
} else {
|
||||
const remDays = Math.max(1, totalDays - elapsedDays);
|
||||
remainingText = totalDays > 0 ? `${remDays} days remaining` : 'Schedule pending';
|
||||
if (phaseIndex === 0) nextMilestoneText = 'Next: SIT Testing';
|
||||
if (phaseIndex === -1) nextMilestoneText = 'Next: Development';
|
||||
else 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';
|
||||
|
||||
Reference in New Issue
Block a user