mirror of
https://github.com/complexcaresolutions/frontend.porwoll.de.git
synced 2026-03-17 18:43:42 +00:00
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:
parent
582dbfbd12
commit
390036f090
1 changed files with 16 additions and 7 deletions
|
|
@ -5,7 +5,8 @@ import { motion } from 'framer-motion'
|
||||||
import { Container } from '../ui/Container'
|
import { Container } from '../ui/Container'
|
||||||
import { Button } from '../ui/Button'
|
import { Button } from '../ui/Button'
|
||||||
import { cn } from '@/lib/utils'
|
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 {
|
interface ContactFormBlockProps {
|
||||||
block: Record<string, unknown>
|
block: Record<string, unknown>
|
||||||
|
|
@ -28,13 +29,21 @@ export function ContactFormBlock({ block }: ContactFormBlockProps) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const formData = new FormData(e.currentTarget)
|
const formData = new FormData(e.currentTarget)
|
||||||
await submitContactForm({
|
const res = await fetch(`${PAYLOAD_URL}/api/form-submissions`, {
|
||||||
name: formData.get('name') as string,
|
method: 'POST',
|
||||||
email: formData.get('email') as string,
|
headers: { 'Content-Type': 'application/json' },
|
||||||
subject: formData.get('subject') as string,
|
body: JSON.stringify({
|
||||||
message: formData.get('message') as string,
|
form: formId || 1,
|
||||||
formId: formId || undefined,
|
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')
|
setStatus('success')
|
||||||
} catch {
|
} catch {
|
||||||
setStatus('error')
|
setStatus('error')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue