interface PurchaseUrl { label: string; url: string; } interface PurchaseUrlFieldsProps { purchaseUrls: PurchaseUrl[]; onChange: (urls: PurchaseUrl[]) => void; } export default function PurchaseUrlFields({ purchaseUrls, onChange }: PurchaseUrlFieldsProps) { const handleAdd = () => { onChange([...purchaseUrls, { label: '', url: '' }]); }; const handleRemove = (index: number) => { onChange(purchaseUrls.filter((_, i) => i !== index)); }; const handleUpdate = (index: number, field: 'label' | 'url', value: string) => { const updated = [...purchaseUrls]; updated[index] = { ...updated[index], [field]: value }; onChange(updated); }; return (
{purchaseUrls.map((urlObj, index) => (
handleUpdate(index, 'label', e.target.value)} className="w-full sm:w-1/3 px-2 py-1.5 text-base border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:bg-gray-700 dark:text-white" /> handleUpdate(index, 'url', e.target.value)} className="flex-1 px-2 py-1.5 text-base border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:bg-gray-700 dark:text-white" />
))}
); }