diff --git a/components/Testimonials.jsx b/components/Testimonials.jsx
new file mode 100644
index 00000000..e69de29b
diff --git a/components/document-card.tsx b/components/document-card.tsx
index 3ecb020d..b59ef150 100644
--- a/components/document-card.tsx
+++ b/components/document-card.tsx
@@ -79,7 +79,7 @@ export function DocumentCard({
className
)}
>
- {/* Animated gradient border effect */}
+
{/* Enhanced shimmer effect */}
diff --git a/components/letter/letter-generator.tsx b/components/letter/letter-generator.tsx
index ed183ef0..3d1a61e6 100644
--- a/components/letter/letter-generator.tsx
+++ b/components/letter/letter-generator.tsx
@@ -38,10 +38,7 @@ export function LetterGenerator() {
const [emailContent, setEmailContent] = useState("");
const [fromEmail, setFromEmail] = useState("");
const { toast } = useToast();
-
- // Email validation function
- const isValidEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
-
+
const generateLetter = async () => {
if (!prompt.trim()) {
toast({
@@ -62,7 +59,7 @@ export function LetterGenerator() {
}
setIsGenerating(true);
-
+
try {
const response = await fetch('/api/generate/letter', {
method: 'POST',
@@ -84,7 +81,7 @@ export function LetterGenerator() {
}
const data = await response.json();
-
+
// Ensure the letter object has the expected structure
const formattedLetter = {
from: {
@@ -103,9 +100,9 @@ export function LetterGenerator() {
subject: data.subject || "Re: " + prompt.substring(0, 30) + "...",
content: data.content || "Letter content not available."
};
-
+
setLetterData(formattedLetter);
-
+
toast({
title: "Letter generated! ✨",
description: "Your professional letter is ready to preview and download",
@@ -124,9 +121,9 @@ export function LetterGenerator() {
const copyToClipboard = async () => {
if (!letterData) return;
-
+
setIsCopying(true);
-
+
try {
const letterText = `
${letterData.from.name || ''}
@@ -141,9 +138,9 @@ Subject: ${letterData.subject || ''}
${letterData.content || ''}
`.trim();
-
+
await navigator.clipboard.writeText(letterText);
-
+
toast({
title: "Copied to clipboard!",
description: "Letter content has been copied to your clipboard",
@@ -161,38 +158,38 @@ ${letterData.content || ''}
const exportToPDF = async () => {
if (!letterData) return;
-
+
setIsExporting(true);
-
+
try {
const element = document.getElementById('letter-preview');
if (!element) throw new Error('Letter preview element not found');
-
+
const canvas = await html2canvas(element, {
scale: 2,
useCORS: true,
allowTaint: true,
backgroundColor: '#ffffff'
});
-
+
const imgData = canvas.toDataURL('image/png');
-
+
// A4 dimensions in mm: 210 x 297
const pdf = new jsPDF('p', 'mm', 'a4');
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
-
+
// Calculate ratio to fit the image within the PDF
const imgWidth = canvas.width;
const imgHeight = canvas.height;
const ratio = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
-
+
const imgX = (pdfWidth - imgWidth * ratio) / 2;
const imgY = 0;
-
+
pdf.addImage(imgData, 'PNG', imgX, imgY, imgWidth * ratio, imgHeight * ratio);
pdf.save(`${letterType}-letter.pdf`);
-
+
toast({
title: "Letter exported!",
description: "Your letter has been downloaded as a PDF.",
@@ -211,30 +208,20 @@ ${letterData.content || ''}
const openSendEmailDialog = () => {
if (!letterData) return;
-
+
// Pre-fill the email form
setEmailTo(letterData.to.name ? `${letterData.to.name} <${letterData.to.email || ''}>` : '');
setEmailSubject(letterData.subject || `${letterType.charAt(0).toUpperCase() + letterType.slice(1)} Letter`);
setEmailContent('');
-
+
setShowEmailDialog(true);
};
const sendEmail = async () => {
if (!letterData || !emailTo) return;
-
- // Validate email before sending
- if (!isValidEmail(emailTo)) {
- toast({
- title: "Invalid Email",
- description: "Please enter a valid recipient email address.",
- variant: "destructive",
- });
- return;
- }
-
+
setIsSending(true);
-
+
try {
const response = await fetch('/api/send-email', {
method: 'POST',
@@ -257,15 +244,15 @@ ${letterData.content || ''}
}
const data = await response.json();
-
+
toast({
title: "Email sent successfully! ✨",
description: "Your letter has been emailed to the recipient",
});
-
+
// Close the dialog
setShowEmailDialog(false);
-
+
// If there's a preview URL (for test emails), show it
if (data.previewUrl) {
window.open(data.previewUrl, '_blank');
@@ -323,7 +310,7 @@ ${letterData.content || ''}
-
+
{/* From/To Information */}
@@ -340,7 +327,7 @@ ${letterData.content || ''}
disabled={isGenerating}
/>
-
+
-
+
-
+
-
+
{/* Prompt */}
-
+
{/* Generate Button */}
)}
-
+
{!isGenerating && (