/** * BulkAddConfirmation - Confirmation modal for bulk adding keywords * Shows preview of keywords to be added and handles the bulk add action */ import { useState } from 'react'; import { Modal } from '../ui/modal'; import Button from '../ui/button/Button'; import { PlusIcon, CheckCircleIcon, AlertIcon } from '../../icons'; import { Spinner } from '../ui/spinner/Spinner'; interface BulkAddConfirmationProps { isOpen: boolean; onClose: () => void; onConfirm: () => Promise<{ added: number; skipped: number; total_requested: number }>; keywordCount: number; sectorName?: string; statTypeLabel?: string; } export default function BulkAddConfirmation({ isOpen, onClose, onConfirm, keywordCount, sectorName, statTypeLabel, }: BulkAddConfirmationProps) { const [isAdding, setIsAdding] = useState(false); const [result, setResult] = useState<{ added: number; skipped: number; total_requested: number } | null>(null); const [error, setError] = useState(null); const handleConfirm = async () => { setIsAdding(true); setError(null); try { const response = await onConfirm(); setResult(response); } catch (err: any) { setError(err.message || 'Failed to add keywords'); } finally { setIsAdding(false); } }; const handleClose = () => { setResult(null); setError(null); onClose(); }; // Success state if (result) { return (

Keywords Added Successfully!

{result.added}

keywords added to your site

{result.skipped > 0 && (

{result.skipped} keywords were skipped (already exist)

)}
); } // Error state if (error) { return (

Failed to Add Keywords

{error}

); } // Confirmation state return (

Add Keywords to Your Site

You're about to add keywords to your site's keyword list.

{/* Summary */}
Keywords to add: {keywordCount}
{sectorName && (
Sector: {sectorName}
)} {statTypeLabel && (
Category: {statTypeLabel}
)}
{/* Actions */}
); }