From 5e0d641575978846bd2c6299a5be11d5bad64228 Mon Sep 17 00:00:00 2001 From: "santasri.pachhal" Date: Thu, 30 Jul 2026 16:43:16 +0530 Subject: [PATCH] fix(ticket): hide details for empty assignment lots --- .../components/TicketAssignmentsCard.tsx | 6 ++-- .../TicketClassDetectionPreview.tsx | 7 ++-- .../components/TicketDefectClassTabs.tsx | 3 +- src/app/(modules)/ticket/[ticketId]/page.tsx | 34 ++++++++++++------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/app/(modules)/ticket/[ticketId]/components/TicketAssignmentsCard.tsx b/src/app/(modules)/ticket/[ticketId]/components/TicketAssignmentsCard.tsx index 1922b8c..e6e3e15 100644 --- a/src/app/(modules)/ticket/[ticketId]/components/TicketAssignmentsCard.tsx +++ b/src/app/(modules)/ticket/[ticketId]/components/TicketAssignmentsCard.tsx @@ -146,7 +146,9 @@ export function TicketAssignmentsCard({ ticketId, initialAssignments, ); - const assignments = assignmentsQuery.data?.items ?? []; + const assignments = (assignmentsQuery.data?.items ?? []).filter( + (assignment) => assignment.item_count > 0, + ); const selectedAssignment = assignments.find((assignment) => assignment.id === selectedAssignmentId) ?? assignments[0]; @@ -178,7 +180,7 @@ export function TicketAssignmentsCard({ {assignmentsQuery.data ? ( - {assignmentsQuery.data.total} + {assignments.length} ) : null} diff --git a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx index 79d09fd..f9fba3f 100644 --- a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx +++ b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx @@ -20,8 +20,7 @@ import { DetectionDiscardDialog } from './DetectionDiscardDialog'; interface TicketClassDetectionPreviewProps { ticketId: string; videoId?: string | null; - assignmentId?: number; - totalCount?: number; + assignmentId: number; } function DetectionMetadataBar({ @@ -96,7 +95,6 @@ export function TicketClassDetectionPreview({ ticketId, videoId, assignmentId, - totalCount, }: TicketClassDetectionPreviewProps) { const [currentIndex, setCurrentIndex] = useState(0); const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false); @@ -122,8 +120,7 @@ export function TicketClassDetectionPreview({ const detectionResult = detectionsQuery.data; const activeDetection = detectionResult?.items[0]; const confirmedDetectionCount = detectionResult?.total; - const detectionCount = - detectionResult?.total ?? (assignmentId ? 0 : (totalCount ?? 0)); + const detectionCount = detectionResult?.total ?? 0; const activeVisual = getDefectVisual( activeDetection?.detection.class_name ?? '', ); diff --git a/src/app/(modules)/ticket/[ticketId]/components/TicketDefectClassTabs.tsx b/src/app/(modules)/ticket/[ticketId]/components/TicketDefectClassTabs.tsx index 1dd1ae0..14129a9 100644 --- a/src/app/(modules)/ticket/[ticketId]/components/TicketDefectClassTabs.tsx +++ b/src/app/(modules)/ticket/[ticketId]/components/TicketDefectClassTabs.tsx @@ -12,7 +12,7 @@ import { TicketClassDetectionPreview } from './TicketClassDetectionPreview'; interface TicketDefectClassTabsProps { ticketId: string; ticket?: TicketOverviewDetail; - assignmentId?: number; + assignmentId: number; } export function TicketDefectClassTabs({ @@ -61,7 +61,6 @@ export function TicketDefectClassTabs({ ticketId={ticketId} videoId={previewVideoId} assignmentId={assignmentId} - totalCount={ticket?.ai_result.detection_count} /> diff --git a/src/app/(modules)/ticket/[ticketId]/page.tsx b/src/app/(modules)/ticket/[ticketId]/page.tsx index bec3a99..fd5682c 100644 --- a/src/app/(modules)/ticket/[ticketId]/page.tsx +++ b/src/app/(modules)/ticket/[ticketId]/page.tsx @@ -43,11 +43,13 @@ export default function TicketDetailPage() { ); const classDetailQuery = useTicketClassDetailQuery(ticketId, defectClass); const classDetail = classDetailQuery.data; - const assignments = assignmentsQuery.data?.items ?? []; - const activeAssignmentId = selectedAssignmentId ?? assignments[0]?.id; - const activeAssignment = assignments.find( - (assignment) => assignment.id === activeAssignmentId, + const assignments = (assignmentsQuery.data?.items ?? []).filter( + (assignment) => assignment.item_count > 0, ); + const activeAssignment = + assignments.find((assignment) => assignment.id === selectedAssignmentId) ?? + assignments[0]; + const activeAssignmentId = activeAssignment?.id; const isClassDetailLoading = Boolean( defectClass && classDetailQuery.isLoading, ); @@ -95,20 +97,26 @@ export default function TicketDetailPage() { onAssignmentChange={setSelectedAssignmentId} /> ) : null} - - {isClassDetailLoading ? : null} - {!isClassDetailLoading && classDetail ? ( + {activeAssignment ? ( + + ) : null} + {activeAssignment && isClassDetailLoading ? ( + + ) : null} + {activeAssignment && !isClassDetailLoading && classDetail ? ( ) : null}
- {isClassDetailLoading ? : null} - {!isClassDetailLoading && classDetail ? ( + {activeAssignment && isClassDetailLoading ? ( + + ) : null} + {activeAssignment && !isClassDetailLoading && classDetail ? (