'use client'; import { type FC, useState } from 'react'; import { type BotTemplate } from '@/lib/bot-templates'; import { TextBox } from '@/components/forms/TextBox'; interface NameStepProps { template: BotTemplate; onSubmit: (name: string, additionalContext?: string) => void; onBack: () => void; } export const NameStep: FC = ({ template, onSubmit, onBack }) => { const [name, setName] = useState(''); const [showOptional, setShowOptional] = useState(false); const [additionalContext, setAdditionalContext] = useState(''); const [relationship, setRelationship] = useState(''); const needsRelationship = template.requiredFields.includes('relationship'); const canSubmit = name.trim().length > 0 && (!needsRelationship || relationship.trim().length > 0); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!canSubmit) return; let context = additionalContext; if (relationship) { context = `Relationship: ${relationship}. ${context}`.trim(); } onSubmit(name.trim(), context.trim() || undefined); }; const getPlaceholder = () => { if (template.category === 'memorial') { if ( template.id.includes('dog') || template.id.includes('cat') || template.id.includes('pet') ) { return 'What was their name?'; } return 'What should I call them?'; } if (template.category === 'helpers') { return 'Give them a name (e.g., Alfred, Jeeves)'; } return template.name; }; const getContextPlaceholder = () => { if (template.category === 'memorial') { return 'Share a memory, their personality, things they used to say, or anything that made them special...'; } return 'Add any specific traits, knowledge, or context you want them to have...'; }; return (
{/* Selected Template Display */}
{template.emoji}
Creating a
{template.name}

{template.category === 'memorial' ? 'Who are you remembering?' : 'Give them a name'}

{template.description}

{/* Form */}
{/* Name Input */}
Name * } multiline={false} id="name" value={name} onValueChange={setName} placeholder={getPlaceholder()} required autoFocus />
{/* Relationship (if required) */} {needsRelationship && (
Relationship * } multiline={false} id="relationship" value={relationship} onValueChange={setRelationship} placeholder="e.g., my brother, my best friend, my mentor" required />
)} {/* Optional Context Toggle */}
{showOptional && (
)}
{/* Actions */}
{/* Starter Questions Preview */}

Example conversations you can have:

{template.starterQuestions.map((question, index) => ( "{question}" ))}
); };