"use client"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { BATCH_SUPPORTED_PROVIDERS, SUPPORTED_BATCH_ENDPOINTS } from "@/lib/batches/types"; import type { WizardDestination } from "@/lib/batches/types"; interface AvailableProvider { id: string; name: string; models: string[]; } interface DestinationStepProps { destination: WizardDestination | null; onChange: (destination: WizardDestination | null) => void; availableProviders: AvailableProvider[]; } export default function DestinationStep({ destination, onChange, availableProviders, }: DestinationStepProps) { const t = useTranslations("common"); // Filter providers to only those with batch support (D16) const batchProviders = availableProviders.filter((p) => BATCH_SUPPORTED_PROVIDERS.includes(p.id as (typeof BATCH_SUPPORTED_PROVIDERS)[number]) ); if (batchProviders.length === 0) { return (
cloud_off

{t("wizardEmptyProviders")}

{t("wizardDestinationConnectProvider")}
); } const selectedProvider = destination?.provider ?? ""; const selectedEndpoint = destination?.endpoint ?? "/v1/chat/completions"; const selectedModel = destination?.model ?? ""; const providerModels = batchProviders.find((p) => p.id === selectedProvider)?.models ?? []; function handleProviderChange(providerId: string) { if (!providerId) { onChange(null); return; } // Validate provider type const validProvider = BATCH_SUPPORTED_PROVIDERS.includes( providerId as (typeof BATCH_SUPPORTED_PROVIDERS)[number] ); if (!validProvider) return; const provider = providerId as WizardDestination["provider"]; const models = batchProviders.find((p) => p.id === provider)?.models ?? []; onChange({ provider, endpoint: selectedEndpoint, model: models[0] ?? "", }); } function handleEndpointChange(endpoint: string) { if (!selectedProvider) return; onChange({ provider: selectedProvider as WizardDestination["provider"], endpoint: endpoint as WizardDestination["endpoint"], model: selectedModel, }); } function handleModelChange(model: string) { if (!selectedProvider) return; onChange({ provider: selectedProvider as WizardDestination["provider"], endpoint: selectedEndpoint, model, }); } const selectClass = "w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg-alt)] " + "px-3 py-2 text-sm text-[var(--color-text)] focus:outline-none " + "focus:ring-1 focus:ring-[var(--color-accent)] disabled:opacity-50"; return (
{/* Provider */}
{/* Endpoint */}
{/* Model */}
); }