diff --git a/src/app/admin/leads/page.tsx b/src/app/admin/leads/page.tsx index d0b6fe9..91975b4 100644 --- a/src/app/admin/leads/page.tsx +++ b/src/app/admin/leads/page.tsx @@ -39,13 +39,14 @@ export default function LeadsPage() { }, []); const handleExportCsv = () => { - const headers = ['Name', 'Email', 'Date Submitted']; + const headers = ['Name', 'Email', 'Phone', 'Date Submitted']; const csvContent = [ headers.join(','), ...leads.map(lead => [ `"${lead.name}"`, `"${lead.email}"`, + `"${lead.phone || ''}"`, `"${format(new Date(lead.createdAt), 'PPP p')}"` ].join(',') ) @@ -85,6 +86,7 @@ export default function LeadsPage() { Name Email + Phone Date Submitted @@ -95,6 +97,7 @@ export default function LeadsPage() { + ))} @@ -104,6 +107,7 @@ export default function LeadsPage() { {lead.name} {lead.email} + {lead.phone || 'N/A'} {format(new Date(lead.createdAt), 'PPP p')} @@ -111,7 +115,7 @@ export default function LeadsPage() { )) ) : ( - + No leads yet. diff --git a/src/components/cost-estimator/step-11-results.tsx b/src/components/cost-estimator/step-11-results.tsx index 8420c7d..5e6011f 100644 --- a/src/components/cost-estimator/step-11-results.tsx +++ b/src/components/cost-estimator/step-11-results.tsx @@ -3,8 +3,8 @@ import type { FormData } from './cost-estimator-form'; import { Button } from '@/components/ui/button'; -import { Card, CardContent } from '@/components/ui/card'; -import { Info, Mail } from 'lucide-react'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Info, Mail, User, Phone, Briefcase, Clock } from 'lucide-react'; import React, { useState, useTransition } from 'react'; import { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip'; import { @@ -20,6 +20,7 @@ import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { useToast } from '@/hooks/use-toast'; import { sendEstimateEmail } from '@/lib/actions/send-estimate'; +import { Separator } from '../ui/separator'; type Step11Props = { onReset: () => void; @@ -123,12 +124,13 @@ export function Step11Results({ onReset, customHours, readyMadeHours, formData } const form = new FormData(event.currentTarget); const name = form.get('name') as string; const email = form.get('email') as string; + const phone = form.get('phone') as string; if (!name || !email) { toast({ variant: "destructive", title: "Missing Information", - description: "Please enter both your name and email.", + description: "Please enter your name and email.", }); return; } @@ -137,6 +139,7 @@ export function Step11Results({ onReset, customHours, readyMadeHours, formData } const result = await sendEstimateEmail({ name, email, + phone, customHours, readyMadeHours, formData, @@ -212,37 +215,66 @@ export function Step11Results({ onReset, customHours, readyMadeHours, formData } - Send Estimate on Email + Send Estimate to Email - - - - Send Estimate - - Enter your name and email to receive the estimate PDF. - - - - - - Name - - - - - - Email - - - - - - - {isPending ? "Sending..." : "Send to Email"} - - - + + + Get Your Detailed Estimate + + Fill out the form below and we'll email you a PDF copy of your estimate. + + + + + + + + Estimate Summary + + + + Custom Development + {customHours}+ hours + + + Ready-Made Tools + {readyMadeHours}+ hours + + + + + + + + + Full Name + + + + + + + Email Address + + + + + + + Phone Number (Optional) + + + + + + + + + + {isPending ? "Sending..." : "Send to Email"} + + diff --git a/src/lib/actions/leads.ts b/src/lib/actions/leads.ts index d7b6c83..755db23 100644 --- a/src/lib/actions/leads.ts +++ b/src/lib/actions/leads.ts @@ -7,13 +7,14 @@ export type Lead = { id: number; name: string; email: string; + phone: string | null; createdAt: string; }; export async function getLeads(): Promise { try { const stmt = db.prepare( - 'SELECT id, name, email, createdAt FROM leads ORDER BY createdAt DESC' + 'SELECT id, name, email, phone, createdAt FROM leads ORDER BY createdAt DESC' ); const leads = stmt.all() as Lead[]; return leads; diff --git a/src/lib/actions/send-estimate.ts b/src/lib/actions/send-estimate.ts index cca01e3..f01141f 100644 --- a/src/lib/actions/send-estimate.ts +++ b/src/lib/actions/send-estimate.ts @@ -11,6 +11,7 @@ import type { FormData } from '@/components/cost-estimator/cost-estimator-form'; const inputSchema = z.object({ name: z.string().min(1), email: z.string().email(), + phone: z.string().optional(), customHours: z.number(), readyMadeHours: z.number(), formData: z.any(), // Keeping this flexible for now @@ -39,7 +40,7 @@ async function getSmtpSettings() { async function createEstimatePdf(data: InputType): Promise { - const { name, customHours, readyMadeHours, formData } = data; + const { name, email, phone, customHours, readyMadeHours, formData } = data; const pdfDoc = await PDFDocument.create(); const page = pdfDoc.addPage(); const { width, height } = page.getSize(); @@ -61,10 +62,16 @@ async function createEstimatePdf(data: InputType): Promise { y -= 30; // Subheader - page.drawText(`Project Estimate for: ${name}`, { x: 50, y, font: boldFont, size: 18 }); + page.drawText('Project Estimate For:', { x: 50, y, font: boldFont, size: 18 }); + y -= 25; + page.drawText(name, { x: 50, y, font: font, size: 14 }); y -= 20; - page.drawText(`Date: ${new Date().toLocaleDateString()}`, { x: 50, y, font, size: 12, color: rgb(0.3, 0.3, 0.3) }); - y -= 40; + page.drawText(email, { x: 50, y, font: font, size: 12, color: rgb(0.3, 0.3, 0.3) }); + y -= 18; + if (phone) { + page.drawText(phone, { x: 50, y, font: font, size: 12, color: rgb(0.3, 0.3, 0.3) }); + } + y -= 30; // Summary page.drawText('Estimate Summary', { x: 50, y, font: boldFont, size: 16 }); @@ -109,10 +116,10 @@ async function createEstimatePdf(data: InputType): Promise { return Buffer.from(pdfBytes); } -async function saveLead(name: string, email: string) { +async function saveLead(name: string, email: string, phone?: string) { try { - const stmt = db.prepare('INSERT INTO leads (name, email) VALUES (?, ?)'); - stmt.run(name, email); + const stmt = db.prepare('INSERT INTO leads (name, email, phone) VALUES (?, ?, ?)'); + stmt.run(name, email, phone || null); console.log(`Lead saved: ${name}, ${email}`); } catch (error) { console.error('Failed to save lead:', error); @@ -160,7 +167,7 @@ export async function sendEstimateEmail(data: InputType): Promise<{ success: boo await transporter.sendMail(mailOptions); // Save lead after email is sent successfully - await saveLead(validation.data.name, validation.data.email); + await saveLead(validation.data.name, validation.data.email, validation.data.phone); return { success: true }; diff --git a/src/lib/db.ts b/src/lib/db.ts index a88a00b..0b0c96c 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -34,6 +34,7 @@ db.exec(` id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT NOT NULL, + phone TEXT, createdAt DATETIME DEFAULT CURRENT_TIMESTAMP ) `);