import { WandSparkles } from 'lucide-react'; import { __ } from '@wordpress/i18n'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import FieldRow from '@/components/FieldRow'; import SwitchField from '@/components/SwitchField'; import ApiKeyField from './ApiKeyField'; import boot from '@/lib/boot'; import { interpolate } from '@/lib/i18n'; import { useOption } from '@/store/settings-store'; import type { ModelsData } from './types'; /** Help under the custom key switch; may link "AI Connector" to Settings > Connectors. */ function CustomKeyHelp( { data }: { data: ModelsData } ) { if ( ! data.connectorsAvailable ) { return <>{ __( 'Enable this to use your own OpenAI API key for content generation.', 'ai-content-generator-for-woocommerce' ) }; } const connectorLink = { __( 'AI Connector', 'ai-content-generator-for-woocommerce' ) }; return ( <> { data.hasConnectorKeys ? interpolate( /** translators: %s: linked term "AI Connector" pointing to Settings > Connectors */ __( 'When off, requests use the %s provider and model selected above.', 'ai-content-generator-for-woocommerce' ), connectorLink ) : interpolate( /** translators: %s: linked term "AI Connector" pointing to Settings > Connectors */ __( 'Enable this to use your own OpenAI API key. Alternatively, configure an %s provider in WordPress settings.', 'ai-content-generator-for-woocommerce' ), connectorLink ) } ); } /** * "API Settings": the setup wizard, the custom ChatGPT key switch and field, * and debug mode. */ export default function ApiSettings( { data }: { data: ModelsData } ) { const [ useCustom, setUseCustom ] = useOption( 'general', 'wtofe_use_custom_api_key' ); const [ debug, setDebug ] = useOption( 'general', 'wtofe_ai_debug_mode' ); return ( { __( 'API Settings', 'ai-content-generator-for-woocommerce' ) } }> { useCustom && ( ) } ); }