Add login prompt when non-authenticated users add items to cart

- Create LoginPromptModal component for authentication encouragement
- Check customer authentication before adding items to cart
- Show modal for non-logged-in users with options to create account, log in, or continue as guest
- Allow guests to add items (stored in IndexedDB) while prompting to sign up
- Implemented in both StandardProductView (ready-made products) and DesignCanvas (personalized items)
- Add server action checkCustomerAuth() for authentication checks

Addresses user request: prompt guests to create account or log in when adding items to cart.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-17 22:53:36 +01:00
co-authored by Claude Haiku 4.5
parent 0cc072fda4
commit b7379e379b
4 changed files with 75 additions and 2 deletions
+6
View File
@@ -5,6 +5,7 @@ import { prisma } from '@/lib/prisma';
import { upsertMailingListEntry } from '@/lib/mailingList';
import { verifyTurnstileToken } from '@/lib/turnstile';
import { getClientIp } from '@/lib/rateLimit';
import { getCurrentCustomer } from '@/lib/auth';
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
@@ -30,3 +31,8 @@ export async function subscribeToNewsletter(email: string, turnstileToken: strin
return { ok: true, message: "Thanks — you're on the list." };
}
export async function checkCustomerAuth() {
const customer = await getCurrentCustomer();
return { isAuthenticated: !!customer };
}