| 10 | const { currentPipeline, updatePipeline } = usePipelineStore(); |
| 11 | |
| 12 | const handleAddUrl = async () => { |
| 13 | if (!newUrl.trim() || !currentPipeline) return; |
| 14 | |
| 15 | // Validate URL |
| 16 | setIsValidating(true); |
| 17 | try { |
| 18 | const response = await api.post('/scraping/validate-url', { url: newUrl }); |
| 19 | |
| 20 | if (response.data.valid) { |
| 21 | const updatedUrls = [...currentPipeline.urls, newUrl]; |
| 22 | updatePipeline(currentPipeline.id, { urls: updatedUrls }); |
| 23 | setNewUrl(''); |
| 24 | } else { |
| 25 | alert(`Invalid URL: ${response.data.error || 'URL is not accessible'}`); |
| 26 | } |
| 27 | } catch (error) { |
| 28 | alert('Failed to validate URL'); |
| 29 | } finally { |
| 30 | setIsValidating(false); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | const handleRemoveUrl = (urlToRemove: string) => { |
| 35 | if (!currentPipeline) return; |