'use client'; import React, { useState } from 'react'; import { Toast } from './Toast'; interface EmailResponderProps { contactEmail: string; contactName: string; originalMessage: string; onClose: () => void; } export const EmailResponder: React.FC = ({ contactEmail, contactName, originalMessage, onClose }) => { const [selectedTemplate, setSelectedTemplate] = useState<'welcome' | 'project' | 'quick'>('welcome'); const [isLoading, setIsLoading] = useState(false); const [showToast, setShowToast] = useState(false); const [toastMessage, setToastMessage] = useState(''); const [toastType, setToastType] = useState<'success' | 'error'>('success'); const templates = { welcome: { name: 'Willkommen', description: 'Freundliche Begrüßung mit Portfolio-Links', icon: '👋', color: 'from-green-500 to-emerald-600' }, project: { name: 'Projekt-Anfrage', description: 'Professionelle Antwort für Projekt-Diskussionen', icon: '🚀', color: 'from-purple-500 to-violet-600' }, quick: { name: 'Schnelle Antwort', description: 'Kurze, schnelle Bestätigung', icon: '⚡', color: 'from-amber-500 to-orange-600' } }; const handleSendEmail = async () => { setIsLoading(true); try { const response = await fetch('/api/email/respond', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ to: contactEmail, name: contactName, template: selectedTemplate, originalMessage: originalMessage }), }); const data = await response.json(); if (response.ok) { setToastMessage(`✅ ${data.message}`); setToastType('success'); setShowToast(true); setTimeout(() => { onClose(); }, 2000); } else { setToastMessage(`❌ ${data.error}`); setToastType('error'); setShowToast(true); } } catch { setToastMessage('❌ Fehler beim Senden der E-Mail'); setToastType('error'); setShowToast(true); } finally { setIsLoading(false); } }; return ( <>
{/* Header */}

📧 E-Mail Antwort senden

Wähle ein schönes Template für deine Antwort

{/* Content */}
{/* Contact Info */}

📬 Kontakt-Informationen

Name:

{contactName}

E-Mail:

{contactEmail}

{/* Original Message Preview */}

💬 Ursprüngliche Nachricht

{originalMessage}

{/* Template Selection */}

🎨 Template auswählen

{Object.entries(templates).map(([key, template]) => (
setSelectedTemplate(key as keyof typeof templates)} >
{template.icon}

{template.name}

{template.description}

{selectedTemplate === key && (
)}
))}
{/* Preview */}

👀 Vorschau

{templates[selectedTemplate].icon} {templates[selectedTemplate].name}

An: {contactName}

{selectedTemplate === 'welcome' && 'Freundliche Begrüßung mit Portfolio-Links und nächsten Schritten'} {selectedTemplate === 'project' && 'Professionelle Projekt-Antwort mit Arbeitsprozess und CTA'} {selectedTemplate === 'quick' && 'Schnelle, kurze Bestätigung der Nachricht'}

{/* Actions */}
{/* Toast */} {showToast && ( setShowToast(false)} /> )} ); };