feat(ticket): enable circular detection preview navigation
This commit is contained in:
@@ -137,11 +137,8 @@ export function TicketClassDetectionPreview({
|
||||
}
|
||||
}, [currentIndex, detectionCount]);
|
||||
|
||||
const isPreviousDisabled = currentIndex === 0 || detectionsQuery.isLoading;
|
||||
const isNextDisabled =
|
||||
detectionCount === 0 ||
|
||||
currentIndex + 1 >= detectionCount ||
|
||||
detectionsQuery.isLoading;
|
||||
const isNavigationDisabled =
|
||||
detectionCount === 0 || detectionsQuery.isLoading;
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -157,9 +154,7 @@ export function TicketClassDetectionPreview({
|
||||
</span>
|
||||
<div className="min-w-0 space-y-1">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<h3 >
|
||||
{displayName}
|
||||
</h3>
|
||||
<h3>{displayName}</h3>
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className={cn(
|
||||
@@ -181,8 +176,14 @@ export function TicketClassDetectionPreview({
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => setCurrentIndex((index) => Math.max(index - 1, 0))}
|
||||
disabled={isPreviousDisabled}
|
||||
onClick={() =>
|
||||
setCurrentIndex((index) =>
|
||||
detectionCount === 0
|
||||
? 0
|
||||
: (index - 1 + detectionCount) % detectionCount,
|
||||
)
|
||||
}
|
||||
disabled={isNavigationDisabled}
|
||||
aria-label="Previous detection"
|
||||
>
|
||||
<ChevronLeft className="size-4" />
|
||||
@@ -195,8 +196,12 @@ export function TicketClassDetectionPreview({
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => setCurrentIndex((index) => index + 1)}
|
||||
disabled={isNextDisabled}
|
||||
onClick={() =>
|
||||
setCurrentIndex((index) =>
|
||||
detectionCount === 0 ? 0 : (index + 1) % detectionCount,
|
||||
)
|
||||
}
|
||||
disabled={isNavigationDisabled}
|
||||
aria-label="Next detection"
|
||||
>
|
||||
<ChevronRight className="size-4" />
|
||||
@@ -231,9 +236,7 @@ export function TicketClassDetectionPreview({
|
||||
<>
|
||||
<div className="grid grid-cols-1 items-start gap-4 xl:grid-cols-2">
|
||||
<div className="min-w-0 space-y-2">
|
||||
<p className="text-muted-foreground">
|
||||
Detection Image
|
||||
</p>
|
||||
<p className="text-muted-foreground">Detection Image</p>
|
||||
<div className="overflow-hidden rounded-lg">
|
||||
<AnnotatedDetectionImage
|
||||
detection={activeDetection}
|
||||
|
||||
Reference in New Issue
Block a user