From 390036f090d38620cce65d284ba903d54e1ffd84 Mon Sep 17 00:00:00 2001 From: CCS Admin Date: Tue, 17 Feb 2026 17:23:30 +0000 Subject: [PATCH] fix(contact): use direct fetch instead of contracts client for form submission The @c2s/payload-contracts API client does not load properly in client-side bundles. Use direct fetch() for the form submission POST request. Co-Authored-By: Claude Opus 4.6 --- src/components/blocks/ContactFormBlock.tsx | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/blocks/ContactFormBlock.tsx b/src/components/blocks/ContactFormBlock.tsx index afcbf17..3650b9a 100644 --- a/src/components/blocks/ContactFormBlock.tsx +++ b/src/components/blocks/ContactFormBlock.tsx @@ -5,7 +5,8 @@ import { motion } from 'framer-motion' import { Container } from '../ui/Container' import { Button } from '../ui/Button' import { cn } from '@/lib/utils' -import { submitContactForm } from '@/lib/api' + +const PAYLOAD_URL = process.env.NEXT_PUBLIC_PAYLOAD_URL || 'https://cms.c2sgmbh.de' interface ContactFormBlockProps { block: Record @@ -28,13 +29,21 @@ export function ContactFormBlock({ block }: ContactFormBlockProps) { try { const formData = new FormData(e.currentTarget) - await submitContactForm({ - name: formData.get('name') as string, - email: formData.get('email') as string, - subject: formData.get('subject') as string, - message: formData.get('message') as string, - formId: formId || undefined, + const res = await fetch(`${PAYLOAD_URL}/api/form-submissions`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + form: formId || 1, + submissionData: [ + { field: 'name', value: formData.get('name') as string }, + { field: 'email', value: formData.get('email') as string }, + { field: 'subject', value: formData.get('subject') as string }, + { field: 'message', value: formData.get('message') as string }, + ], + }), }) + + if (!res.ok) throw new Error(`HTTP ${res.status}`) setStatus('success') } catch { setStatus('error')