17 Commits

Author SHA1 Message Date
e5fd3ec8e8 Switch to version 11: remove .env.local.example 2026-03-06 08:25:00 +00:00
3eb21771d1 Switch to version 11: modified src/app/page.tsx 2026-03-06 08:25:00 +00:00
2f113b3b0f Switch to version 11: modified src/app/api/waitlist/route.ts 2026-03-06 08:25:00 +00:00
f4eeb48f17 Switch to version 11: modified package.json 2026-03-06 08:24:59 +00:00
26507f4126 Merge version_12 into main
Merge version_12 into main
2026-03-06 08:11:44 +00:00
0924e85ee7 Update src/app/api/waitlist/route.ts 2026-03-06 08:11:40 +00:00
416688826f Merge version_12 into main
Merge version_12 into main
2026-03-06 08:00:16 +00:00
e80dcca1a8 Update src/app/page.tsx 2026-03-06 08:00:12 +00:00
6b7ca8c352 Merge version_12 into main
Merge version_12 into main
2026-03-06 07:59:13 +00:00
416ab0fb9c Update src/app/page.tsx 2026-03-06 07:59:09 +00:00
fc3c5dbe19 Update src/app/api/waitlist/route.ts 2026-03-06 07:59:09 +00:00
a3258ea000 Update package.json 2026-03-06 07:59:09 +00:00
80eda59319 Add .env.local.example 2026-03-06 07:59:08 +00:00
63f1f58dc9 Merge version_11 into main
Merge version_11 into main
2026-03-06 06:25:29 +00:00
8f96928c52 Update src/app/page.tsx 2026-03-06 06:25:25 +00:00
92065771c3 Update src/app/api/waitlist/route.ts 2026-03-06 06:25:25 +00:00
1792646e60 Merge version_10 into main
Merge version_10 into main
2026-03-06 06:18:37 +00:00
2 changed files with 60 additions and 43 deletions

View File

@@ -1,7 +1,15 @@
import { NextRequest, NextResponse } from 'next/server';
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || '';
const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || '';
interface WaitlistEntry {
email: string;
instagram?: string;
tiktok?: string;
createdAt: string;
}
// In-memory storage for demonstration
// In production, replace with actual database (MongoDB, PostgreSQL, etc.)
const waitlistEntries: WaitlistEntry[] = [];
export async function POST(request: NextRequest) {
try {
@@ -9,61 +17,70 @@ export async function POST(request: NextRequest) {
const { email, instagram, tiktok } = body;
// Validate email
if (!email || !email.includes('@')) {
if (!email || typeof email !== 'string' || !email.includes('@')) {
return NextResponse.json(
{ error: 'Invalid email address' },
{ error: 'Valid email is required' },
{ status: 400 }
);
}
// Check if Supabase credentials are configured
if (!SUPABASE_URL || !SUPABASE_ANON_KEY) {
console.error('Supabase credentials not configured');
// Still return success to user, but log the error
// Check for duplicate email
if (waitlistEntries.some(entry => entry.email === email)) {
return NextResponse.json(
{ message: 'Submission received (database pending)' },
{ status: 202 }
{ error: 'Email already registered' },
{ status: 409 }
);
}
// Insert into Supabase
const response = await fetch(`${SUPABASE_URL}/rest/v1/waitlist`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': SUPABASE_ANON_KEY,
'Authorization': `Bearer ${SUPABASE_ANON_KEY}`,
},
body: JSON.stringify({
email,
instagram: instagram || null,
tiktok: tiktok || null,
created_at: new Date().toISOString(),
}),
});
// Create waitlist entry
const entry: WaitlistEntry = {
email,
instagram: instagram || undefined,
tiktok: tiktok || undefined,
createdAt: new Date().toISOString()
};
if (!response.ok) {
console.error('Supabase error:', await response.text());
// Check if it's a duplicate entry error
const errorText = await response.text();
if (errorText.includes('duplicate') || errorText.includes('unique')) {
return NextResponse.json(
{ error: 'This email is already on the waitlist' },
{ status: 409 }
);
}
throw new Error(`Supabase error: ${response.status}`);
}
// Add to in-memory storage
waitlistEntries.push(entry);
// TODO: In production, save to database here
// Example for MongoDB:
// await db.collection('waitlist').insertOne(entry);
// TODO: Send confirmation email
// Example:
// await sendEmail({
// to: email,
// subject: 'Welcome to Clearance Waitlist',
// template: 'waitlist-confirmation'
// });
console.log('Waitlist entry created:', entry);
return NextResponse.json(
{ message: 'Successfully joined the waitlist' },
{
success: true,
message: 'Successfully joined the waitlist',
data: entry
},
{ status: 201 }
);
} catch (error) {
console.error('Waitlist API error:', error);
return NextResponse.json(
{ error: 'Failed to process waitlist submission' },
{ error: 'Internal server error' },
{ status: 500 }
);
}
}
export async function GET() {
// Optional: Get all waitlist entries (add authentication in production)
return NextResponse.json(
{
count: waitlistEntries.length,
entries: waitlistEntries
},
{ status: 200 }
);
}

View File

@@ -39,7 +39,6 @@ export default function LandingPage() {
const handleWaitlistSubmit = async (formData: WaitlistFormData) => {
try {
// Send to database via API
const response = await fetch('/api/waitlist', {
method: 'POST',
headers: {
@@ -49,13 +48,15 @@ export default function LandingPage() {
});
if (!response.ok) {
throw new Error('Failed to submit form');
const errorData = await response.json();
throw new Error(errorData.error || 'Failed to submit form');
}
const responseData = await response.json();
setWaitlistData([...waitlistData, formData]);
setFormStatus('success');
setTimeout(() => setFormStatus('idle'), 3000);
console.log('Waitlist submission:', formData);
console.log('Waitlist submission successful:', responseData);
} catch (error) {
setFormStatus('error');
console.error('Error submitting waitlist form:', error);
@@ -65,7 +66,6 @@ export default function LandingPage() {
const handleJoinWaitlistClick = () => {
if (contactFormRef.current) {
contactFormRef.current.scrollIntoView({ behavior: 'smooth' });
// Focus on the email input after scroll
setTimeout(() => {
const emailInput = contactFormRef.current?.querySelector('input[type="email"]') as HTMLInputElement;
if (emailInput) {