'; // Convert HTML to Blob const blob = new Blob([htmlContent], { type: 'application/vnd.ms-word;charset=utf-8' }); // Create download link and trigger download const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = 'Affiliate-Agreement.doc'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } catch (error) { console.error("Error generating Word document:", error); alert("Error generating Word document. Please try again or use the copy option."); } }; // Main component const AffiliateAgreementGenerator = () => { const [formData, setFormData] = useState({ companyName: '', affiliateName: '' }); const [agreementText, setAgreementText] = useState( `AFFILIATE AGREEMENT This Affiliate Agreement is entered into by and between: [COMPANY NAME] ("Company"), and [AFFILIATE NAME] ("Affiliate").` ); // Update agreement text when form data changes useEffect(() => { let updatedText = `AFFILIATE AGREEMENT This Affiliate Agreement is entered into by and between: ${formData.companyName || '[COMPANY NAME]'} ("Company"), and ${formData.affiliateName || '[AFFILIATE NAME]'} ("Affiliate").`; setAgreementText(updatedText); }, [formData]); const handleChange = (e) => { const { name, value } = e.target; setFormData(prev => ({ ...prev, [name]: value })); }; const copyToClipboard = () => { try { navigator.clipboard.writeText(agreementText); alert('Agreement copied to clipboard!'); } catch (error) { console.error('Error copying to clipboard:', error); alert('Failed to copy to clipboard. Please try again.'); } }; const downloadAsWord = () => { generateWordDoc(agreementText, formData); }; return (

Affiliate Agreement Generator

Preview:

{agreementText}
); }; // Render the app ReactDOM.render( , document.getElementById('root') );