'use server';

import { redirect } from 'next/navigation';
import { prisma } from '@/lib/prisma';

export async function startDesignWithProduct(formData: FormData, customRequestId: string) {
  const productId = String(formData.get('productId') ?? '');
  if (!productId) return;

  const product = await prisma.product.findUnique({ where: { id: productId } });
  if (product) {
    redirect(`/made-to-order/${product.slug}?customRequestId=${customRequestId}`);
  }
}
