Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

2.6 KB
Raw Blame
"use client";

import { useTranslations } from "next-intl";

export interface FreeProxyRowData {
  id: string;
  source: string;
  host: string;
  port: number;
  type: string;
  countryCode: string | null;
  qualityScore: number | null;
  latencyMs: number | null;
  anonymity: string | null;
  inPool: boolean;
}

interface FreeProxyRowProps {
  proxy: FreeProxyRowData;
  selected: boolean;
  onToggleSelect: (id: string) => void;
  onAddToPool: (id: string) => void;
  adding: boolean;
}

export default function FreeProxyRow({
  proxy,
  selected,
  onToggleSelect,
  onAddToPool,
  adding,
}: FreeProxyRowProps) {
  const t = useTranslations("settings");
  const qualityColor =
    proxy.qualityScore == null
      ? "text-text-muted"
      : proxy.qualityScore >= 80
        ? "text-emerald-400"
        : proxy.qualityScore >= 50
          ? "text-yellow-400"
          : "text-red-400";

  return (
    <tr className="border-b border-border/50 hover:bg-surface-alt/30 text-sm">
      <td className="px-3 py-2">
        <input
          type="checkbox"
          checked={selected}
          onChange={() => onToggleSelect(proxy.id)}
          className="rounded"
          disabled={proxy.inPool}
          aria-label={t("proxyFreePoolSelectProxy", { endpoint: `${proxy.host}:${proxy.port}` })}
        />
      </td>
      <td className="px-3 py-2 text-text-muted text-xs">{proxy.source}</td>
      <td className="px-3 py-2 font-mono text-xs">
        {proxy.host}:{proxy.port}
      </td>
      <td className="px-3 py-2 uppercase text-xs">{proxy.type}</td>
      <td className="px-3 py-2 text-xs">{proxy.countryCode || "—"}</td>
      <td className={`px-3 py-2 text-xs font-semibold ${qualityColor}`}>
        {proxy.qualityScore != null ? proxy.qualityScore : "—"}
      </td>
      <td className="px-3 py-2 text-xs">
        {proxy.latencyMs != null ? `${proxy.latencyMs}ms` : "—"}
      </td>
      <td className="px-3 py-2">
        {proxy.inPool ? (
          <span className="px-2 py-0.5 rounded text-xs bg-emerald-500/15 text-emerald-400 border border-emerald-500/30">
            {t("proxyFreePoolInPool")}
          </span>
        ) : (
          <button
            onClick={() => onAddToPool(proxy.id)}
            disabled={adding}
            aria-label={t("proxyFreePoolAddProxy", { endpoint: `${proxy.host}:${proxy.port}` })}
            className="px-2 py-0.5 rounded text-xs bg-primary/15 text-primary border border-primary/30 hover:bg-primary/25 disabled:opacity-50"
          >
            {adding ? t("proxyFreePoolAdding") : "⊕"}
          </button>
        )}
      </td>
    </tr>
  );
}