'use client'; import { useState } from 'react'; import { STYLES } from '@/lib/types'; export default function OrderPage(){ const [loading,setLoading]=useState(false); const [msg,setMsg]=useState(''); async function submit(e:React.FormEvent){e.preventDefault();setLoading(true);setMsg(''); const fd=new FormData(e.currentTarget); const files=fd.getAll('photos') as File[]; if(files.length<3||files.length>6){setMsg('Upload minimaal 3 en maximaal 6 foto’s.'); setLoading(false); return;} const res=await fetch('/api/orders/create',{method:'POST',body:fd}); const data=await res.json(); if(!res.ok){setMsg(data.error||'Er ging iets mis.');setLoading(false);return;} const pay=await fetch('/api/payments/session',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({orderId:data.orderId})}); const p=await pay.json(); if(!pay.ok){setMsg(p.error||'Betaling kon niet starten.');setLoading(false);return;} window.location.href=p.redirectUrl || `/order/checkout?orderId=${data.orderId}`; } return
WEDDING cake topper

Start jouw ontwerp