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 <noreply@anthropic.com>
This commit is contained in:
CCS Admin 2026-02-17 17:23:30 +00:00
parent 582dbfbd12
commit 390036f090

View file

@ -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<string, unknown>
@ -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')