Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.8 KB
Raw Blame
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { useLocalize } from '~/hooks';

interface ResultSwitcherProps {
  currentIndex: number;
  totalCount: number;
  onPrevious: () => void;
  onNext: () => void;
}

export default function ResultSwitcher({
  currentIndex,
  totalCount,
  onPrevious,
  onNext,
}: ResultSwitcherProps) {
  const localize = useLocalize();

  if (totalCount <= 1) {
    return null;
  }

  const atFirst = currentIndex === 0;
  const atLast = currentIndex === totalCount - 1;

  return (
    <nav
      aria-label={localize('com_ui_navigate_results')}
      className="border-border-inset bg-surface-code flex items-center justify-center gap-1.5 border-t px-3 py-1.5 text-xs"
    >
      <button
        type="button"
        onClick={onPrevious}
        disabled={atFirst}
        aria-label={localize('com_ui_prev_result')}
        className="text-text-tertiary hover:bg-surface-hover hover:text-text-primary focus:outline-focus-subtle rounded p-0.5 transition-colors focus:outline focus:outline-2 disabled:pointer-events-none disabled:opacity-30"
      >
        <ChevronLeft className="size-3.5 rtl:-scale-x-100" aria-hidden="true" />
      </button>
      <span className="text-text-secondary min-w-[3ch] text-center tabular-nums select-none">
        <bdi>
          {currentIndex + 1}/{totalCount}
        </bdi>
      </span>
      <button
        type="button"
        onClick={onNext}
        disabled={atLast}
        aria-label={localize('com_ui_next_result')}
        className="text-text-tertiary hover:bg-surface-hover hover:text-text-primary focus:outline-focus-subtle rounded p-0.5 transition-colors focus:outline focus:outline-2 disabled:pointer-events-none disabled:opacity-30"
      >
        <ChevronRight className="size-3.5 rtl:-scale-x-100" aria-hidden="true" />
      </button>
    </nav>
  );
}