mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Align assignment status pipeline UI
This update prioritizes technical status and date-matched assignment status resolution, then falls back to project status when needed. It also tightens milestone/timeline behavior by removing the deploy phase, reordering the stage flow, and adding tooltips for assignment codes, project info, and date ranges. The assignment list and overview helpers now use the resolved status consistently across the dashboard.
This commit is contained in:
+89
-16
@@ -13,6 +13,9 @@ import { Card900 } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger, TooltipProvider,
|
||||
} from '@/components/ui/tooltip';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { IClient, CLIENT_FALLBACK_IMAGE, END_USER_FALLBACK_IMAGE } from '../../../types';
|
||||
@@ -94,7 +97,40 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date;
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date;
|
||||
const assignmentDesc = assignment.wo_description || assignment.im_description;
|
||||
const assignmentStatus = assignment.project?.status || assignment.project_assignment_status?.name;
|
||||
|
||||
// Status assignment: priority project_assignment_technical_status.name,
|
||||
// otherwise project_assignment_status_detail matching today's date,
|
||||
// fallback to project_assignment_status / project status
|
||||
const resolveCurrentStatus = (): string | null => {
|
||||
if (assignment.project_assignment_technical_status?.name) {
|
||||
return assignment.project_assignment_technical_status.name;
|
||||
}
|
||||
const details = assignment.project_assignment_status_detail || [];
|
||||
const now = Date.now();
|
||||
const activeDetail = details.find((d) => {
|
||||
const sTime = d.start_date ? new Date(d.start_date).getTime() : null;
|
||||
const eTime = d.end_date ? new Date(d.end_date).getTime() : null;
|
||||
if (sTime && eTime) return now >= sTime && now <= eTime;
|
||||
if (sTime && !eTime) return now >= sTime;
|
||||
if (Array.isArray(d.date)) {
|
||||
return d.date.some((item) => {
|
||||
const s = item?.start_date ? new Date(item.start_date).getTime() : null;
|
||||
const e = item?.end_date ? new Date(item.end_date).getTime() : null;
|
||||
return s && e && now >= s && now <= e;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return (
|
||||
activeDetail?.project_assignment_status?.name ||
|
||||
assignment.project_assignment_status?.name ||
|
||||
assignment.project?.status ||
|
||||
null
|
||||
);
|
||||
};
|
||||
|
||||
// const assignmentStatus = resolveCurrentStatus();
|
||||
const assignmentStatus = assignment.project_assignment_status.name
|
||||
|
||||
const owner = client ?? assignment.client;
|
||||
const clientHref = owner?.id ? `/task/client-detail/${owner.id}` : '/task';
|
||||
@@ -158,9 +194,17 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
<ConvertedAssignmentBadge assignment={assignment} clientId={owner?.id} />
|
||||
{assignmentStatus ? <BadgeStatus status={assignmentStatus} /> : null}
|
||||
{assignmentCode ? (
|
||||
<span className="rounded-lg border border-border bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground">
|
||||
# {assignmentCode}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="rounded-lg border border-border bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground cursor-help hover:border-border transition-colors">
|
||||
# {assignmentCode}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="text-xs">
|
||||
<p className="font-semibold text-popover-foreground">Assignment Code</p>
|
||||
<p className="font-mono text-[11px] text-muted-foreground mt-0.5">{assignmentCode}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -237,10 +281,23 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground pt-1">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Calendar className="h-3.5 w-3.5 text-muted-foreground/70" />
|
||||
<span>{dateRangeText}</span>
|
||||
</div>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="flex items-center gap-1.5 shrink-0 cursor-help hover:text-foreground transition-colors">
|
||||
<Calendar className="h-3.5 w-3.5 text-muted-foreground/70 shrink-0" />
|
||||
<span>{dateRangeText}</span>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="text-xs">
|
||||
<p className="font-semibold text-popover-foreground">Assignment Timeline</p>
|
||||
<p className="text-[11px] text-muted-foreground mt-1">
|
||||
Start: <span className="text-primary">{assignmentStartDate ? formatAssignmentDate(assignmentStartDate) : 'Start date not set'}</span>
|
||||
</p>
|
||||
<p className="text-[11px] text-muted-foreground">
|
||||
End: <span className="text-primary">{assignmentEndDate ? formatAssignmentDate(assignmentEndDate) : 'End date not set'}</span>
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div className="flex items-center gap-1.5 font-mono text-[11px]">
|
||||
<Clock className="h-3.5 w-3.5 text-muted-foreground/70" />
|
||||
<span>{totalDaysText}</span>
|
||||
@@ -308,16 +365,32 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{assignment.project.code ? (
|
||||
<span className="inline-flex items-center rounded-md border border-border/80 bg-muted/60 px-2 py-0.5 font-mono text-xs font-medium text-foreground/90">
|
||||
<span className="mr-0.5 text-muted-foreground">#</span>
|
||||
{assignment.project.code}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="inline-flex items-center rounded-md border border-border/80 bg-muted/60 px-2 py-0.5 font-mono text-xs font-medium text-foreground/90 cursor-help hover:border-border transition-colors">
|
||||
<span className="mr-0.5 text-muted-foreground">#</span>
|
||||
{assignment.project.code}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="text-xs">
|
||||
<p className="font-semibold text-popover-foreground">Project Code</p>
|
||||
<p className="font-mono text-[11px] text-muted-foreground mt-0.5">{assignment.project.code}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
{assignment.project.year ? (
|
||||
<span className="inline-flex items-center gap-1 rounded-md border border-border/60 bg-muted/20 px-2 py-0.5 text-xs text-muted-foreground">
|
||||
<Calendar className="h-3 w-3 text-muted-foreground/70" />
|
||||
<span>Year {assignment.project.year}</span>
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="inline-flex items-center gap-1 rounded-md border border-border/60 bg-muted/20 px-2 py-0.5 text-xs text-muted-foreground cursor-help hover:text-foreground transition-colors">
|
||||
<Calendar className="h-3 w-3 text-muted-foreground/70" />
|
||||
<span>Year {assignment.project.year}</span>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="text-xs">
|
||||
<p className="font-semibold text-popover-foreground">Project Year</p>
|
||||
<p className="text-[11px] text-muted-foreground mt-0.5">Fiscal Year {assignment.project.year}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
{assignment.project.start_date || assignment.project.end_date ? (
|
||||
<span className="inline-flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
|
||||
+38
-83
@@ -149,16 +149,14 @@ export function ProjectMilestoneTimeline({
|
||||
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 (techName.includes('deploy')) techRank = 5;
|
||||
else if (techId === 10 || techName.includes('go-live') || techName.includes('live')) techRank = 6;
|
||||
else if (techId === 11 || techName.includes('bast') || techName.includes('handover')) techRank = 7;
|
||||
else if (techId === 12 || techName.includes('warranty')) techRank = 8;
|
||||
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;
|
||||
|
||||
// Checkpoint dates
|
||||
const sitEndTime = (sitDetail?.end_date || sitDetail?.start_date) ? dayjs(sitDetail?.end_date || sitDetail?.start_date).valueOf() : null;
|
||||
const uatEndTime = (uatDetail?.end_date || uatDetail?.start_date) ? dayjs(uatDetail?.end_date || uatDetail?.start_date).valueOf() : null;
|
||||
const ptrEndTime = (ptrDetail?.end_date || ptrDetail?.start_date) ? dayjs(ptrDetail?.end_date || ptrDetail?.start_date).valueOf() : null;
|
||||
const deployEndTime = (deployDetail?.end_date || deployDetail?.start_date) ? dayjs(deployDetail?.end_date || deployDetail?.start_date).valueOf() : null;
|
||||
const goLiveEndTime = (goLiveDetail?.end_date || goLiveDetail?.start_date) ? dayjs(goLiveDetail?.end_date || goLiveDetail?.start_date).valueOf() : null;
|
||||
const bastEndTime = (bastDetail?.end_date || bastDetail?.start_date) ? dayjs(bastDetail?.end_date || bastDetail?.start_date).valueOf() : null;
|
||||
|
||||
@@ -166,34 +164,31 @@ export function ProjectMilestoneTimeline({
|
||||
* Determine dynamic position of 'Today'
|
||||
* For assignment 36: SIT ended 12 Oct, Today is 14 Oct, UAT starts 15 Oct -> insertAfter = 'sit'!
|
||||
*/
|
||||
const insertTodayAfter = useMemo<'start' | 'dev' | 'sit' | 'uat' | 'ptr' | 'deploy' | 'golive' | 'bast'>(() => {
|
||||
const insertTodayAfter = useMemo<'start' | 'dev' | 'sit' | 'uat' | 'ptr' | 'golive' | 'bast'>(() => {
|
||||
if (bastEndTime && todayVal >= bastEndTime) return 'bast';
|
||||
if (techRank >= 7) return 'golive';
|
||||
if (techRank >= 6) return 'golive';
|
||||
if (goLiveEndTime && todayVal >= goLiveEndTime) return 'golive';
|
||||
if (techRank >= 6) return 'deploy';
|
||||
if (deployEndTime && todayVal >= deployEndTime) return 'deploy';
|
||||
if (techRank >= 5) return 'ptr';
|
||||
if (ptrEndTime && todayVal >= ptrEndTime) return 'ptr';
|
||||
if (techRank >= 4) return 'uat';
|
||||
if (uatEndTime && todayVal >= uatEndTime) return 'uat';
|
||||
if (techRank >= 3 || (sitEndTime && todayVal >= sitEndTime)) return 'sit';
|
||||
if (sitEndTime && todayVal >= sitEndTime) return 'sit';
|
||||
if (techRank >= 2) return 'dev';
|
||||
if (effectiveStart && todayVal < dayjs(effectiveStart).valueOf()) return 'start';
|
||||
return 'dev';
|
||||
}, [todayVal, techRank, bastEndTime, goLiveEndTime, deployEndTime, ptrEndTime, uatEndTime, sitEndTime, effectiveStart]);
|
||||
}, [todayVal, techRank, bastEndTime, goLiveEndTime, ptrEndTime, uatEndTime, sitEndTime, effectiveStart]);
|
||||
|
||||
// Active status highlights
|
||||
// Active status highlights matching technical progression colors
|
||||
const isDevActive = techRank === 1 || techName.includes('dev');
|
||||
const isSitActive = techRank === 2;
|
||||
const isUatActive = techRank === 3;
|
||||
const isPtrActive = techRank === 4;
|
||||
const isDeployActive = techRank === 5;
|
||||
const isGoLiveActive = techRank === 6;
|
||||
const isBastActive = techRank === 7;
|
||||
const isGoLiveActive = techRank === 5;
|
||||
const isBastActive = techRank === 6;
|
||||
const isWarrantyActive = techRank === 7;
|
||||
|
||||
return (
|
||||
<section className="rounded-2xl border border-border/80 bg-card p-5 sm:p-6 transition-all duration-200">
|
||||
<section className="rounded-2xl border border-border/80 bg-card p-5 sm:p-6 pb-0 sm:pb-0 transition-all duration-200">
|
||||
{/* Header */}
|
||||
<div className="mb-4 flex items-center justify-between gap-3">
|
||||
<h2 className="flex items-center gap-2.5 text-base font-semibold tracking-tight text-foreground">
|
||||
@@ -203,7 +198,7 @@ export function ProjectMilestoneTimeline({
|
||||
</div>
|
||||
|
||||
{/* Continuous Timeline Rail Container with Horizontal Scroll */}
|
||||
<div className="overflow-x-auto pb-4 pt-4 scrollbar-thin">
|
||||
<div className="overflow-x-auto pb-2 scrollbar-thin">
|
||||
<div className="min-w-255 px-4 py-8 flex items-center justify-between">
|
||||
{/* 1. START NODE */}
|
||||
<div className="relative shrink-0 flex flex-col items-center">
|
||||
@@ -300,7 +295,7 @@ export function ProjectMilestoneTimeline({
|
||||
{/* 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-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isSitActive ? 'text-[#3b82f6] font-semibold' : 'text-foreground'}`}>
|
||||
SIT
|
||||
</span>
|
||||
</div>
|
||||
@@ -340,7 +335,7 @@ export function ProjectMilestoneTimeline({
|
||||
{/* 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-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isUatActive ? 'text-[#a855f7] font-semibold' : 'text-foreground'}`}>
|
||||
UAT
|
||||
</span>
|
||||
</div>
|
||||
@@ -374,17 +369,17 @@ export function ProjectMilestoneTimeline({
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Continuous Yellow Line connecting to PTR */}
|
||||
<div className="flex-1 h-0.75 bg-[#eab308]" />
|
||||
{/* Continuous Teal Line connecting to PTR */}
|
||||
<div className="flex-1 h-0.75 bg-[#14b8a6]" />
|
||||
|
||||
{/* 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-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isPtrActive ? 'text-[#14b8a6] font-semibold' : 'text-foreground'}`}>
|
||||
PTR
|
||||
</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-[#14b8a6] bg-white 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">
|
||||
@@ -396,7 +391,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{insertTodayAfter === 'ptr' && (
|
||||
<>
|
||||
<div className="flex-1 h-0.75 bg-[#eab308]" />
|
||||
<div className="flex-1 h-0.75 bg-[#14b8a6]" />
|
||||
<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">
|
||||
@@ -414,57 +409,17 @@ export function ProjectMilestoneTimeline({
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Continuous Cyan Line connecting to Deployment */}
|
||||
<div className="flex-1 h-0.75 bg-[#06b6d4]" />
|
||||
{/* Continuous Green Line connecting to Go Live */}
|
||||
<div className="flex-1 h-0.75 bg-[#22c55e]" />
|
||||
|
||||
{/* 6. DEPLOYMENT NODE */}
|
||||
{/* 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 ${isDeployActive ? 'text-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
Deployment
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#06b6d4] bg-white z-10 shadow-xs" />
|
||||
{deployDateFormatted && (
|
||||
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
|
||||
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap">
|
||||
{deployDateFormatted}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{insertTodayAfter === 'deploy' && (
|
||||
<>
|
||||
<div className="flex-1 h-0.75 bg-[#06b6d4]" />
|
||||
<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">
|
||||
Today
|
||||
</div>
|
||||
<div className="w-0.5 h-3 bg-[#ea512c]" />
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-[#ea512c] 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}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Continuous Pink Line connecting to Go Live */}
|
||||
<div className="flex-1 h-0.75 bg-[#ec4899]" />
|
||||
|
||||
{/* 7. 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-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isGoLiveActive ? 'text-[#22c55e] font-semibold' : 'text-foreground'}`}>
|
||||
Go Live
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#ec4899] bg-white z-10 shadow-xs" />
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#22c55e] bg-white 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">
|
||||
@@ -476,7 +431,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{insertTodayAfter === 'golive' && (
|
||||
<>
|
||||
<div className="flex-1 h-0.75 bg-[#ec4899]" />
|
||||
<div className="flex-1 h-0.75 bg-[#22c55e]" />
|
||||
<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">
|
||||
@@ -494,17 +449,17 @@ export function ProjectMilestoneTimeline({
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Continuous Rose Line connecting to BAST */}
|
||||
<div className="flex-1 h-0.75 bg-[#f43f5e]" />
|
||||
{/* Continuous Yellow Line connecting to BAST */}
|
||||
<div className="flex-1 h-0.75 bg-[#eab308]" />
|
||||
|
||||
{/* 8. BAST NODE */}
|
||||
{/* 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-[#ea512c] font-semibold' : 'text-foreground'}`}>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isBastActive ? 'text-[#eab308] font-semibold' : 'text-foreground'}`}>
|
||||
BAST
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#f43f5e] bg-white z-10 shadow-xs" />
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-[#eab308] bg-white 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">
|
||||
@@ -516,7 +471,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{insertTodayAfter === 'bast' && (
|
||||
<>
|
||||
<div className="flex-1 h-0.75 bg-[#f43f5e]" />
|
||||
<div className="flex-1 h-0.75 bg-[#eab308]" />
|
||||
<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">
|
||||
@@ -537,18 +492,18 @@ export function ProjectMilestoneTimeline({
|
||||
{/* Vertical Dashed Separator */}
|
||||
<div className="h-10 border-r border-dashed border-zinc-700 mx-5 shrink-0" />
|
||||
|
||||
{/* 9. WARRANTY CAPSULE TRACK */}
|
||||
{/* 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 text-foreground whitespace-nowrap">
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${isWarrantyActive ? 'text-[#0ea5e9] font-semibold' : 'text-foreground'}`}>
|
||||
Warranty
|
||||
</span>
|
||||
</div>
|
||||
{/* Capsule with < ---- > indicator */}
|
||||
<div className="flex items-center justify-between rounded-full border border-zinc-700 bg-zinc-800/80 px-2.5 py-0.5 text-zinc-400 w-36 sm:w-44 z-10">
|
||||
<ChevronLeft className="h-3 w-3 text-zinc-300" />
|
||||
<div className="h-0.5 flex-1 bg-zinc-500/70 mx-1" />
|
||||
<ChevronRight className="h-3 w-3 text-zinc-300" />
|
||||
{/* 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" />
|
||||
</div>
|
||||
{/* Dates below warranty: strictly empty if not set */}
|
||||
{(warrantyStart || warrantyEnd) && (
|
||||
|
||||
@@ -156,7 +156,7 @@ export default function AssignmentList({
|
||||
</span>
|
||||
|
||||
{/* Project Status Badge matching technical status badge colors */}
|
||||
<BadgeStatus status={item.projectStatusName} />
|
||||
<BadgeStatus status={assignment.project_assignment_status.name} />
|
||||
|
||||
{/* Code Pill with Tooltip */}
|
||||
{item.code ? (
|
||||
|
||||
@@ -188,38 +188,32 @@ export function getTechnicalStageRank(rawName?: string | null): number {
|
||||
|
||||
/**
|
||||
* 1. Derives project status:
|
||||
* Taken from project_assignment_status_detail, if not present or all dates are null fallback to project_assignment_status.name
|
||||
* 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'
|
||||
*/
|
||||
export function resolveProjectStatus(assignment: IProjectAssignment, indexFallback = 0): {
|
||||
statusName: string;
|
||||
isFromDetail: boolean;
|
||||
phaseIndex: number;
|
||||
} {
|
||||
// 1. Technical status priority
|
||||
if (assignment.project_assignment_technical_status?.name) {
|
||||
const rawName = assignment.project_assignment_technical_status.name;
|
||||
return {
|
||||
statusName: formatShortPhaseName(rawName),
|
||||
isFromDetail: false,
|
||||
phaseIndex: mapStatusNameToPhaseIndex(rawName),
|
||||
};
|
||||
}
|
||||
|
||||
const details = assignment.project_assignment_status_detail || [];
|
||||
|
||||
// Filter only entries that actually have dates assigned
|
||||
const detailsWithDates = details.filter(hasAssignedDates);
|
||||
|
||||
// If NO detail has dates assigned (e.g. all start_date/end_date/date are null)
|
||||
// -> 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',
|
||||
isFromDetail: false,
|
||||
phaseIndex: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// If there ARE details with assigned dates:
|
||||
// Determine which detail is active right now or the latest assigned stage
|
||||
// 2. Check if any detail matches today's date
|
||||
const now = Date.now();
|
||||
let activeDetail: any = null;
|
||||
|
||||
@@ -251,8 +245,34 @@ export function resolveProjectStatus(assignment: IProjectAssignment, indexFallba
|
||||
}
|
||||
}
|
||||
|
||||
// If no stage is active today, pick the latest stage with dates (last one in chronological progression)
|
||||
const chosen = activeDetail || detailsWithDates[detailsWithDates.length - 1];
|
||||
if (activeDetail?.project_assignment_status?.name) {
|
||||
const rawName = activeDetail.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',
|
||||
isFromDetail: false,
|
||||
phaseIndex: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
||||
Reference in New Issue
Block a user