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')