import { TextField, Button, Box, Alert } from '@mui/material'; import { useState } from 'react'; function DocumentInput() { const [url, setUrl] = useState(''); const [showSuccess, setShowSuccess] = useState(false); const handleSubmit = async () => { try { const response = await fetch('/api/crawl/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ url }), }); if (!response.ok) throw new Error('Network response was not ok'); setShowSuccess(true); } catch (error) { console.error('Error:', error); } }; const handleUrlChange = (e: React.ChangeEvent) => { setUrl(e.target.value); if (showSuccess) { setShowSuccess(false); } }; return ( {showSuccess && ( Source documentation imported successfully! )} ); } export default DocumentInput;