import React from "react"; import { useTranslation } from "react-i18next"; import { Wand2 } from "lucide-react"; import { toast } from "sonner"; import { formatJSON } from "@/utils/formatters"; interface CodexAuthSectionProps { value: string; onChange: (value: string) => void; onBlur?: () => void; error?: string; } /** * CodexAuthSection - Auth JSON editor section */ export const CodexAuthSection: React.FC = ({ value, onChange, onBlur, error, }) => { const { t } = useTranslation(); const handleFormat = () => { if (!value.trim()) return; try { const formatted = formatJSON(value); onChange(formatted); toast.success(t("common.formatSuccess", { defaultValue: "格式化成功" })); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); toast.error( t("common.formatError", { defaultValue: "格式化失败:{{error}}", error: errorMessage, }), ); } }; return (