fix(ticket): hide details for empty assignment lots
This commit is contained in:
@@ -146,7 +146,9 @@ export function TicketAssignmentsCard({
|
|||||||
ticketId,
|
ticketId,
|
||||||
initialAssignments,
|
initialAssignments,
|
||||||
);
|
);
|
||||||
const assignments = assignmentsQuery.data?.items ?? [];
|
const assignments = (assignmentsQuery.data?.items ?? []).filter(
|
||||||
|
(assignment) => assignment.item_count > 0,
|
||||||
|
);
|
||||||
const selectedAssignment =
|
const selectedAssignment =
|
||||||
assignments.find((assignment) => assignment.id === selectedAssignmentId) ??
|
assignments.find((assignment) => assignment.id === selectedAssignmentId) ??
|
||||||
assignments[0];
|
assignments[0];
|
||||||
@@ -178,7 +180,7 @@ export function TicketAssignmentsCard({
|
|||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
{assignmentsQuery.data ? (
|
{assignmentsQuery.data ? (
|
||||||
<Badge variant="secondary">{assignmentsQuery.data.total}</Badge>
|
<Badge variant="secondary">{assignments.length}</Badge>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ import { DetectionDiscardDialog } from './DetectionDiscardDialog';
|
|||||||
interface TicketClassDetectionPreviewProps {
|
interface TicketClassDetectionPreviewProps {
|
||||||
ticketId: string;
|
ticketId: string;
|
||||||
videoId?: string | null;
|
videoId?: string | null;
|
||||||
assignmentId?: number;
|
assignmentId: number;
|
||||||
totalCount?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function DetectionMetadataBar({
|
function DetectionMetadataBar({
|
||||||
@@ -96,7 +95,6 @@ export function TicketClassDetectionPreview({
|
|||||||
ticketId,
|
ticketId,
|
||||||
videoId,
|
videoId,
|
||||||
assignmentId,
|
assignmentId,
|
||||||
totalCount,
|
|
||||||
}: TicketClassDetectionPreviewProps) {
|
}: TicketClassDetectionPreviewProps) {
|
||||||
const [currentIndex, setCurrentIndex] = useState(0);
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false);
|
const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false);
|
||||||
@@ -122,8 +120,7 @@ export function TicketClassDetectionPreview({
|
|||||||
const detectionResult = detectionsQuery.data;
|
const detectionResult = detectionsQuery.data;
|
||||||
const activeDetection = detectionResult?.items[0];
|
const activeDetection = detectionResult?.items[0];
|
||||||
const confirmedDetectionCount = detectionResult?.total;
|
const confirmedDetectionCount = detectionResult?.total;
|
||||||
const detectionCount =
|
const detectionCount = detectionResult?.total ?? 0;
|
||||||
detectionResult?.total ?? (assignmentId ? 0 : (totalCount ?? 0));
|
|
||||||
const activeVisual = getDefectVisual(
|
const activeVisual = getDefectVisual(
|
||||||
activeDetection?.detection.class_name ?? '',
|
activeDetection?.detection.class_name ?? '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { TicketClassDetectionPreview } from './TicketClassDetectionPreview';
|
|||||||
interface TicketDefectClassTabsProps {
|
interface TicketDefectClassTabsProps {
|
||||||
ticketId: string;
|
ticketId: string;
|
||||||
ticket?: TicketOverviewDetail;
|
ticket?: TicketOverviewDetail;
|
||||||
assignmentId?: number;
|
assignmentId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TicketDefectClassTabs({
|
export function TicketDefectClassTabs({
|
||||||
@@ -61,7 +61,6 @@ export function TicketDefectClassTabs({
|
|||||||
ticketId={ticketId}
|
ticketId={ticketId}
|
||||||
videoId={previewVideoId}
|
videoId={previewVideoId}
|
||||||
assignmentId={assignmentId}
|
assignmentId={assignmentId}
|
||||||
totalCount={ticket?.ai_result.detection_count}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ export default function TicketDetailPage() {
|
|||||||
);
|
);
|
||||||
const classDetailQuery = useTicketClassDetailQuery(ticketId, defectClass);
|
const classDetailQuery = useTicketClassDetailQuery(ticketId, defectClass);
|
||||||
const classDetail = classDetailQuery.data;
|
const classDetail = classDetailQuery.data;
|
||||||
const assignments = assignmentsQuery.data?.items ?? [];
|
const assignments = (assignmentsQuery.data?.items ?? []).filter(
|
||||||
const activeAssignmentId = selectedAssignmentId ?? assignments[0]?.id;
|
(assignment) => assignment.item_count > 0,
|
||||||
const activeAssignment = assignments.find(
|
|
||||||
(assignment) => assignment.id === activeAssignmentId,
|
|
||||||
);
|
);
|
||||||
|
const activeAssignment =
|
||||||
|
assignments.find((assignment) => assignment.id === selectedAssignmentId) ??
|
||||||
|
assignments[0];
|
||||||
|
const activeAssignmentId = activeAssignment?.id;
|
||||||
const isClassDetailLoading = Boolean(
|
const isClassDetailLoading = Boolean(
|
||||||
defectClass && classDetailQuery.isLoading,
|
defectClass && classDetailQuery.isLoading,
|
||||||
);
|
);
|
||||||
@@ -95,20 +97,26 @@ export default function TicketDetailPage() {
|
|||||||
onAssignmentChange={setSelectedAssignmentId}
|
onAssignmentChange={setSelectedAssignmentId}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
{activeAssignment ? (
|
||||||
<TicketDefectClassTabs
|
<TicketDefectClassTabs
|
||||||
ticketId={ticketId}
|
ticketId={ticketId}
|
||||||
ticket={overview}
|
ticket={overview}
|
||||||
assignmentId={activeAssignmentId}
|
assignmentId={activeAssignment.id}
|
||||||
/>
|
/>
|
||||||
{isClassDetailLoading ? <TicketClassContentSkeleton /> : null}
|
) : null}
|
||||||
{!isClassDetailLoading && classDetail ? (
|
{activeAssignment && isClassDetailLoading ? (
|
||||||
|
<TicketClassContentSkeleton />
|
||||||
|
) : null}
|
||||||
|
{activeAssignment && !isClassDetailLoading && classDetail ? (
|
||||||
<TicketHistoryCard ticket={classDetail} />
|
<TicketHistoryCard ticket={classDetail} />
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0 space-y-3 self-start xl:min-h-0 xl:self-stretch xl:overflow-y-auto xl:overscroll-contain xl:pr-2">
|
<div className="min-w-0 space-y-3 self-start xl:min-h-0 xl:self-stretch xl:overflow-y-auto xl:overscroll-contain xl:pr-2">
|
||||||
{isClassDetailLoading ? <TicketClassActionsSkeleton /> : null}
|
{activeAssignment && isClassDetailLoading ? (
|
||||||
{!isClassDetailLoading && classDetail ? (
|
<TicketClassActionsSkeleton />
|
||||||
|
) : null}
|
||||||
|
{activeAssignment && !isClassDetailLoading && classDetail ? (
|
||||||
<TicketStatusActions
|
<TicketStatusActions
|
||||||
ticket={classDetail}
|
ticket={classDetail}
|
||||||
assignment={activeAssignment}
|
assignment={activeAssignment}
|
||||||
|
|||||||
Reference in New Issue
Block a user