diff --git a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx index 99d7b98..fa7dde2 100644 --- a/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx +++ b/src/app/(modules)/ticket/[ticketId]/components/TicketClassDetectionPreview.tsx @@ -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 (
@@ -157,9 +154,7 @@ export function TicketClassDetectionPreview({
-

- {displayName} -

+

{displayName}

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" > @@ -195,8 +196,12 @@ export function TicketClassDetectionPreview({