diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx index e552145..0be37e7 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx @@ -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 {assignmentStatus ? : null} {assignmentCode ? ( - - # {assignmentCode} - + + + + # {assignmentCode} + + + +

Assignment Code

+

{assignmentCode}

+
+
) : null} @@ -237,10 +281,23 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
-
- - {dateRangeText} -
+ + +
+ + {dateRangeText} +
+
+ +

Assignment Timeline

+

+ Start: {assignmentStartDate ? formatAssignmentDate(assignmentStartDate) : 'Start date not set'} +

+

+ End: {assignmentEndDate ? formatAssignmentDate(assignmentEndDate) : 'End date not set'} +

+
+
{totalDaysText} @@ -308,16 +365,32 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
{assignment.project.code ? ( - - # - {assignment.project.code} - + + + + # + {assignment.project.code} + + + +

Project Code

+

{assignment.project.code}

+
+
) : null} {assignment.project.year ? ( - - - Year {assignment.project.year} - + + + + + Year {assignment.project.year} + + + +

Project Year

+

Fiscal Year {assignment.project.year}

+
+
) : null} {assignment.project.start_date || assignment.project.end_date ? ( 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 c2ab248..cef9cb9 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 @@ -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 ( -
+
{/* Header */}

@@ -203,7 +198,7 @@ export function ProjectMilestoneTimeline({

{/* Continuous Timeline Rail Container with Horizontal Scroll */} -
+
{/* 1. START NODE */}
@@ -300,7 +295,7 @@ export function ProjectMilestoneTimeline({ {/* 3. SIT NODE */}
- + SIT
@@ -340,7 +335,7 @@ export function ProjectMilestoneTimeline({ {/* 4. UAT NODE */}
- + UAT
@@ -374,17 +369,17 @@ export function ProjectMilestoneTimeline({ )} - {/* Continuous Yellow Line connecting to PTR */} -
+ {/* Continuous Teal Line connecting to PTR */} +
{/* 5. PTR NODE */}
- + PTR
-
+
{ptrDateFormatted && (
@@ -396,7 +391,7 @@ export function ProjectMilestoneTimeline({ {insertTodayAfter === 'ptr' && ( <> -
+
@@ -414,57 +409,17 @@ export function ProjectMilestoneTimeline({ )} - {/* Continuous Cyan Line connecting to Deployment */} -
+ {/* Continuous Green Line connecting to Go Live */} +
- {/* 6. DEPLOYMENT NODE */} + {/* 6. GO LIVE NODE */}
- - Deployment - -
-
- {deployDateFormatted && ( -
- - {deployDateFormatted} - -
- )} -
- - {insertTodayAfter === 'deploy' && ( - <> -
-
-
-
- Today -
-
-
-
-
- - {todayFormatted} - -
-
- - )} - - {/* Continuous Pink Line connecting to Go Live */} -
- - {/* 7. GO LIVE NODE */} -
-
- + Go Live
-
+
{goLiveDateFormatted && (
@@ -476,7 +431,7 @@ export function ProjectMilestoneTimeline({ {insertTodayAfter === 'golive' && ( <> -
+
@@ -494,17 +449,17 @@ export function ProjectMilestoneTimeline({ )} - {/* Continuous Rose Line connecting to BAST */} -
+ {/* Continuous Yellow Line connecting to BAST */} +
- {/* 8. BAST NODE */} + {/* 7. BAST NODE */}
- + BAST
-
+
{bastDateFormatted && (
@@ -516,7 +471,7 @@ export function ProjectMilestoneTimeline({ {insertTodayAfter === 'bast' && ( <> -
+
@@ -537,18 +492,18 @@ export function ProjectMilestoneTimeline({ {/* Vertical Dashed Separator */}
- {/* 9. WARRANTY CAPSULE TRACK */} + {/* 8. WARRANTY CAPSULE TRACK */}
- + Warranty
- {/* Capsule with < ---- > indicator */} -
- -
- + {/* Capsule with < ---- > indicator matching Sky Blue techWarranty */} +
+ +
+
{/* Dates below warranty: strictly empty if not set */} {(warrantyStart || warrantyEnd) && ( diff --git a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx index c16acdd..038779e 100644 --- a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx +++ b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx @@ -156,7 +156,7 @@ export default function AssignmentList({ {/* Project Status Badge matching technical status badge colors */} - + {/* Code Pill with Tooltip */} {item.code ? ( diff --git a/app/(dashboard)/task/utils/assignment-overview-helpers.ts b/app/(dashboard)/task/utils/assignment-overview-helpers.ts index b40b296..7c3499b 100644 --- a/app/(dashboard)/task/utils/assignment-overview-helpers.ts +++ b/app/(dashboard)/task/utils/assignment-overview-helpers.ts @@ -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 {