From 76c87811d8db98d700c9817d2fe1c54878b1f786 Mon Sep 17 00:00:00 2001 From: "santasri.pachhal" Date: Tue, 21 Jul 2026 19:24:40 +0530 Subject: [PATCH] feat(tickets): add repair proof status filter for class issues --- .../TicketClassDetectionPreview.tsx | 67 ++++++++++-- .../components/TicketStatusActions.tsx | 13 +-- .../actions/SubmittedRepairProofAction.tsx | 1 - .../components/repair/RepairProofGallery.tsx | 14 ++- .../components/repair/RepairProofSummary.tsx | 103 ------------------ .../repair/RepairSubmittedBanner.tsx | 27 +++++ .../video/annotatedDetectionImage.tsx | 82 +++++++++++--- src/types/detection.ts | 11 ++ 8 files changed, 172 insertions(+), 146 deletions(-) delete mode 100644 src/app/(modules)/ticket/[ticketId]/components/actions/SubmittedRepairProofAction.tsx delete mode 100644 src/app/(modules)/ticket/[ticketId]/components/repair/RepairProofSummary.tsx create mode 100644 src/app/(modules)/ticket/[ticketId]/components/repair/RepairSubmittedBanner.tsx diff --git a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx index 07c779a..1be4b2e 100644 --- a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx +++ b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx @@ -1,7 +1,13 @@ 'use client'; import { useEffect, useMemo, useState } from 'react'; -import { AlertTriangle, ChevronLeft, ChevronRight, Trash2 } from 'lucide-react'; +import { + AlertTriangle, + ChevronLeft, + ChevronRight, + ImageIcon, + Trash2, +} from 'lucide-react'; import DetectionLocationMap from '@/components/map/detectionLocationMap'; import { Badge } from '@/components/ui/badge'; @@ -10,12 +16,15 @@ import { Skeleton } from '@/components/ui/skeleton'; import AnnotatedDetectionImage from '@/components/video/annotatedDetectionImage'; import { getDefectVisual } from '@/constants/defectVisualConfig'; import { cn } from '@/lib/utils'; +import type { DetectionRepairProof } from '@/types'; import { useDiscardDetectionMutation, useTicketClassDetectionsQuery, } from '../../hooks/useTicketQueries'; import { DetectionDiscardDialog } from './DetectionDiscardDialog'; +import { RepairProofGallery } from './repair/RepairProofGallery'; +import { RepairSubmittedBanner } from './repair/RepairSubmittedBanner'; interface TicketClassDetectionPreviewProps { ticketId: string; @@ -54,6 +63,44 @@ function DetectionMetadataBar({ ); } +function DetectionRepairProofPanel({ + repairProof, +}: { + repairProof: DetectionRepairProof; +}) { + if (!repairProof.submitted) { + return null; + } + + return ( +
+
+ +

Repair Proof

+
+ + {repairProof.submitted_at ? ( + + ) : null} + + + +
+

Repair Notes

+

+ {repairProof.notes?.trim() || 'No repair notes provided.'} +

+
+
+ ); +} + function TicketClassDetectionPreviewSkeleton() { return ( <> @@ -131,12 +178,6 @@ export function TicketClassDetectionPreview({ const detectionResult = detectionsQuery.data; const activeDetection = detectionResult?.items[0]; const detectionCount = detectionResult?.total ?? totalCount ?? 0; - const mediaAspectRatio = - detectionResult && - detectionResult.video_width > 0 && - detectionResult.video_height > 0 - ? `${detectionResult.video_width} / ${detectionResult.video_height}` - : '16 / 9'; useEffect(() => { if (detectionCount === 0 && currentIndex !== 0) { @@ -249,11 +290,13 @@ export function TicketClassDetectionPreview({

Detection Image

-
+
@@ -265,7 +308,7 @@ export function TicketClassDetectionPreview({ label={`${displayName} - Frame ${activeDetection.frame.number}`} title="Location on Map" variant="plain" - aspectRatio={mediaAspectRatio} + aspectRatio="16 / 9" showCoordinates={false} />
@@ -287,6 +330,12 @@ export function TicketClassDetectionPreview({ ]} /> + {activeDetection.repair_proof ? ( + + ) : null} +
+ + + + + {detection.detection.display_name} annotated detection image + +
+ {annotatedMedia} +
+
+
+ + ); + } return (
Failed to load the detection image.

) : ( - <> - {`${detection.detection.display_name} - - + annotatedMedia )}
); diff --git a/src/types/detection.ts b/src/types/detection.ts index c81b316..f3ee7fa 100644 --- a/src/types/detection.ts +++ b/src/types/detection.ts @@ -22,6 +22,16 @@ export type BoundingBoxOverlayItem = { bounding_box: DetectionBoundingBox; }; +export type DetectionRepairProof = { + submitted: boolean; + review_status: 'pending' | 'approved' | 'rejected'; + notes: string | null; + proof_image_urls: string[]; + submitted_at: string | null; + reviewed_at: string | null; + review_comment: string | null; +}; + export type DetectionResultItem = { id: string; detection: { @@ -42,6 +52,7 @@ export type DetectionResultItem = { latitude: number | null; longitude: number | null; }; + repair_proof: DetectionRepairProof | null; }; export type DetectionResultLog = DetectionResultItem & {