diff --git a/new frontend1/.gitignore b/frontend/.gitignore similarity index 100% rename from new frontend1/.gitignore rename to frontend/.gitignore diff --git a/new frontend1/LICENSE b/frontend/LICENSE similarity index 100% rename from new frontend1/LICENSE rename to frontend/LICENSE diff --git a/new frontend1/README.md b/frontend/README.md similarity index 100% rename from new frontend1/README.md rename to frontend/README.md diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx deleted file mode 100644 index 75e44d8..0000000 --- a/frontend/app/page.tsx +++ /dev/null @@ -1,286 +0,0 @@ -'use client' -import { useState, useEffect } from 'react' -import { - Send, - Sparkles, - Copy, - Check, - RotateCcw, - Trash2, - History, - X, -} from 'lucide-react' - -// Type definition for a History Item -type ReplyHistory = { - id: string - email: string - context: string - tone: string - text: string - timestamp: number -} - -export default function ReplyGenerator() { - const [email, setEmail] = useState('') - const [context, setContext] = useState('') - const [replies, setReplies] = useState<{ tone: string; text: string }[]>([]) - const [history, setHistory] = useState([]) - const [isLoading, setIsLoading] = useState(false) - const [copiedIndex, setCopiedIndex] = useState(null) - const [showHistory, setShowHistory] = useState(false) - - // Load history from localStorage on mount - useEffect(() => { - const savedHistory = localStorage.getItem('reply_history') - if (savedHistory) setHistory(JSON.parse(savedHistory)) - }, []) - - // Save history to localStorage whenever it changes - useEffect(() => { - localStorage.setItem('reply_history', JSON.stringify(history)) - }, [history]) - - const generateReplies = async (selectedTone: string) => { - if (!email.trim()) return alert('Please paste an email first!') - - setIsLoading(true) - try { - const response = await fetch('/api/generate-reply', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email, context, tone: selectedTone }), - }) - - const data = await response.json() - const newReplyText = data.reply - - // 1. Update Current View - setReplies([{ tone: selectedTone, text: newReplyText }, ...replies]) - - // 2. Add to Local History - const newHistoryItem: ReplyHistory = { - id: crypto.randomUUID(), - email, - context, - tone: selectedTone, - text: newReplyText, - timestamp: Date.now(), - } - setHistory([newHistoryItem, ...history]) - } catch (error) { - console.error('Failed to generate:', error) - } finally { - setIsLoading(false) - } - } - - const deleteHistoryItem = (id: string) => { - setHistory(history.filter((item) => item.id !== id)) - } - - const clearAllHistory = () => { - if (confirm('Are you sure you want to delete all history?')) { - setHistory([]) - } - } - - const loadFromHistory = (item: ReplyHistory) => { - setEmail(item.email) - setContext(item.context) - setReplies([{ tone: item.tone, text: item.text }]) - setShowHistory(false) - } - - const copyToClipboard = (text: string, index: number) => { - navigator.clipboard.writeText(text) - setCopiedIndex(index) - setTimeout(() => setCopiedIndex(null), 2000) - } - - return ( -
- {/* History Toggle Button */} - - - {/* History Slide-over Component */} - {showHistory && ( -
-
-
-

- Generation Vault -

- -
- - {history.length > 0 ? ( -
- - {history.map((item) => ( -
-
- - {item.tone} - - -
-

loadFromHistory(item)} - > - {item.text} -

-
- - {new Date(item.timestamp).toLocaleDateString()} - - -
-
- ))} -
- ) : ( -
-
- -
-

- No history yet. Start generating! -

-
- )} -
-
- )} - - {/* Main UI Header */} -
-

- AI Email Reply Generator -

-

- Professional drafts tailored to your brand voice. -

-
- - {/* Input Area */} -
-
- -