import React, { useState, useEffect } from 'react' import './Integrations.css' function TodoistIntegration({ onBack }) { const [webhookURL, setWebhookURL] = useState('') const [loading, setLoading] = useState(true) const [copied, setCopied] = useState(false) useEffect(() => { fetchWebhookURL() }, []) const fetchWebhookURL = async () => { try { setLoading(true) const response = await fetch('/api/integrations/todoist/webhook-url') if (!response.ok) { throw new Error('Ошибка при загрузке URL webhook') } const data = await response.json() setWebhookURL(data.webhook_url) } catch (error) { console.error('Error fetching webhook URL:', error) } finally { setLoading(false) } } const copyToClipboard = async () => { try { await navigator.clipboard.writeText(webhookURL) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch (error) { console.error('Error copying to clipboard:', error) } } return (