import React, { useEffect, useState } from 'react'; import type { PromptResponse } from '../../service/visibility/visibility.interface'; import { regeneratePrompts } from '../../service/visibility/visibility.service'; import Modal from './Modal'; /** Props for {@link RegeneratePromptsModal}. */ interface RegeneratePromptsModalProps { open: boolean; onClose: () => void; /** Called with the freshly generated prompts after the backend confirms. */ onRegenerated: (prompts: PromptResponse[]) => void; clientId: string; token: string; brandId: string; } /** * Explains what regeneration does and lets the merchant steer it before * rebuilding the tracked prompt set. The backend re-reads the live storefront * so the new prompts stay inside the real catalog; the optional guidance and * business-type override correct cases the auto-detection got wrong. * * @param {RegeneratePromptsModalProps} props - Dialog props. * @returns {JSX.Element} The modal. */ const RegeneratePromptsModal = ({ open, onClose, onRegenerated, clientId, token, brandId, }: RegeneratePromptsModalProps): JSX.Element => { const [guidance, setGuidance] = useState(''); const [businessType, setBusinessType] = useState(''); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (open) setError(null); }, [open]); const handleRegenerate = async (): Promise => { setSubmitting(true); setError(null); try { const res = await regeneratePrompts(clientId, token, brandId, { custom_guidance: guidance.trim() || undefined, business_type: businessType.trim() || undefined, }); onRegenerated(res.prompts || []); onClose(); } catch (err) { setError( err instanceof Error ? err.message : 'Failed to regenerate prompts.' ); } finally { setSubmitting(false); } }; return ( } >
{error && (
{error}
)}

We re-read your live website to see what you actually sell, then rebuild all 16 prompts so they stay inside your real catalog. This replaces the current set and takes up to 1-2 minutes. Your past scan history is kept.