diff --git a/public/blog/sustainable-packaging-qr.png b/public/blog/sustainable-packaging-qr.png new file mode 100644 index 0000000..f6c69c8 Binary files /dev/null and b/public/blog/sustainable-packaging-qr.png differ diff --git a/scripts/verify-lead-db.ts b/scripts/verify-lead-db.ts new file mode 100644 index 0000000..9548a01 --- /dev/null +++ b/scripts/verify-lead-db.ts @@ -0,0 +1,34 @@ + +import { db } from '../src/lib/db'; + +async function main() { + try { + console.log('Verifying Lead model...'); + // Type assertion to bypass potential type generation issues locally if they exist + const leadCount = await (db as any).lead.count(); + console.log(`Current lead count: ${leadCount}`); + + const testLead = await (db as any).lead.create({ + data: { + email: 'test_verify@example.com', + source: 'verification-script', + reprintCost: 100, + updatesPerYear: 12, + annualSavings: 1200, + }, + }); + console.log('Successfully created test lead:', testLead.id); + + // Clean up + await (db as any).lead.delete({ + where: { id: testLead.id } + }); + console.log('Successfully deleted test lead'); + + } catch (error) { + console.error('Verification failed:', error); + process.exit(1); + } +} + +main(); diff --git a/src/app/api/leads/route.ts b/src/app/api/leads/route.ts index 5e39df5..66424e9 100644 --- a/src/app/api/leads/route.ts +++ b/src/app/api/leads/route.ts @@ -1,5 +1,6 @@ import { NextResponse } from 'next/server'; import { db } from '@/lib/db'; +import { Prisma } from '@prisma/client'; interface LeadInput { email: string; @@ -37,6 +38,20 @@ export async function POST(request: Request) { return NextResponse.json({ success: true, id: lead.id }); } catch (error) { console.error('Error saving lead:', error); + + if (error instanceof Prisma.PrismaClientKnownRequestError) { + if (error.code === 'P2021') { + console.error('CRITICAL: Table "Lead" does not exist in the database. Run "npx prisma migrate deploy" to fix this.'); + return NextResponse.json( + { + error: 'Database configuration error', + details: 'Missing database table. Please run migrations.' + }, + { status: 500 } + ); + } + } + // Return the actual error message for debugging purposes return NextResponse.json( { diff --git a/verify_output.txt b/verify_output.txt new file mode 100644 index 0000000..28265d9 Binary files /dev/null and b/verify_output.txt differ