Design Canvas (Primary) - FabricDesignCanvasV2: Fabric.js-based product customization canvas - Lazy-loads Fabric.js to minimize bundle impact - Renders product mockup with print area guide (magenta dashed box) - Supports front/back view switching with correct product images - Color swatch selection for garment customization - Text element creation with selection handles and transform controls - Fixed React dependency array to prevent infinite renders Support Components - DesignCanvasWrapper: Client-side wrapper for SSR compatibility - DesignCanvasErrorBoundary: Error boundary for canvas failures - ThemeInitializer: Theme detection and application Configuration - Updated .claude/launch.json with dev server settings - Updated .claude/settings.local.json with local preferences - Updated next.config.mjs for production build optimization - Dependency updates in package.json and package-lock.json Known Issues & TODO - Image element rendering disabled (Fabric.js compatibility investigation) - Text editing UI controls needed (font, size, color pickers) - Delete/undo functionality pending - Print area alignment needs visual verification - "Add to Cart" integration with design serialization pending Testing Artifacts - check_*.js: Product verification scripts for debugging Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
'use server';
|
|
|
|
import { headers } from 'next/headers';
|
|
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@]+$/;
|
|
|
|
export async function subscribeToNewsletter(email: string, turnstileToken: string) {
|
|
const trimmed = email.trim().toLowerCase();
|
|
if (!EMAIL_RE.test(trimmed)) {
|
|
return { ok: false, message: 'Enter a valid email address.' };
|
|
}
|
|
|
|
const ip = getClientIp(await headers());
|
|
const { success } = await verifyTurnstileToken(turnstileToken, ip);
|
|
if (!success) {
|
|
return { ok: false, message: 'CAPTCHA verification failed — please try again.' };
|
|
}
|
|
|
|
await prisma.newsletterSubscriber.upsert({
|
|
where: { email: trimmed },
|
|
create: { email: trimmed },
|
|
update: {},
|
|
});
|
|
|
|
await upsertMailingListEntry({ email: trimmed, source: 'NEWSLETTER' });
|
|
|
|
return { ok: true, message: "Thanks — you're on the list." };
|
|
}
|
|
|
|
export async function checkCustomerAuth() {
|
|
const customer = await getCurrentCustomer();
|
|
return { isAuthenticated: !!customer };
|
|
}
|