import { __ } from '@wordpress/i18n'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Textarea } from '@/components/ui/textarea'; import PageHeader from '@/components/layout/PageHeader'; import SaveButton from '@/components/layout/SaveButton'; import FieldRow from '@/components/FieldRow'; import ModelSelect from '@/components/ModelSelect'; import SwitchField from '@/components/SwitchField'; import PageVisibility from './PageVisibility'; import ChatHistory from './ChatHistory'; import { useOption, useSettingsStore } from '@/store/settings-store'; import type { PageProps } from '@/pages/registry'; import type { ChatbotData } from './types'; const GROUP = 'chatbot'; function ColorField( { option, label }: { option: string; label: string } ) { const [ value, setValue ] = useOption( GROUP, option ); return ( ); } /** A text option of this page as an input. */ function useTextOption( option: string ) { const [ value, setValue ] = useOption( GROUP, option ); return { value: value ?? '', onChange: ( next: string ) => setValue( next ), }; } /** * "Chatbot": storefront/admin chatbot settings (own option group and Save * button), followed by the chat history manager. */ export default function ChatbotPage( { section, title }: PageProps ) { const { data } = section; const textModels = useSettingsStore( ( state ) => state.models.text_generation ) ?? {}; const hasModels = Object.keys( textModels ).length > 0; const [ enabled, setEnabled ] = useOption( GROUP, 'wtofe_chatbot_enabled' ); const [ allowGuests, setAllowGuests ] = useOption( GROUP, 'wtofe_chatbot_allow_guests' ); const [ adminBubble, setAdminBubble ] = useOption( GROUP, 'wtofe_chatbot_admin_bubble' ); const [ avatar, setAvatar ] = useOption( GROUP, 'wtofe_chatbot_avatar_url' ); const [ model, setModel ] = useOption( GROUP, 'wtofe_chatbot_model' ); const name = useTextOption( 'wtofe_chatbot_name' ); const welcome = useTextOption( 'wtofe_chatbot_welcome_message' ); const placeholder = useTextOption( 'wtofe_chatbot_placeholder' ); const maxTokens = useTextOption( 'wtofe_ai_max_tokens_chatbot' ); const temperature = useTextOption( 'wtofe_ai_temperature_chatbot' ); const historyDays = useTextOption( 'wtofe_chatbot_max_history_days' ); const saveButton = ; return ( <>
{ enabled && ( ) } { __( 'Appearance', 'ai-content-generator-for-woocommerce' ) } { avatar && ( { ) }