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