'use client'; import React, { useState } from 'react'; import { CATEGORY_LABELS, type RobotCategory } from '@/data/robots'; type Props = { defaultRobot?: string; defaultCategory?: RobotCategory | ''; intent?: 'inquiry' | 'demo' | 'quotation'; }; const INTENT_LABEL: Record, string> = { inquiry: 'Send inquiry', demo: 'Book live demo', quotation: 'Request quotation', }; export function InquiryForm({ defaultRobot = '', defaultCategory = '', intent = 'inquiry' }: Props) { const [data, setData] = useState({ name: '', company: '', email: '', phone: '', robotInterest: defaultRobot, category: defaultCategory as string, message: '', }); const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle'); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); setStatus('loading'); try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: data.name, email: data.email, phone: data.phone, message: `[${intent.toUpperCase()}] from ${data.company || 'Individual'}\n` + `Robot interest: ${data.robotInterest || 'N/A'}\n` + `Category: ${data.category || 'N/A'}\n\n` + data.message, }), }); if (res.ok) { setStatus('success'); setData({ name: '', company: '', email: '', phone: '', robotInterest: defaultRobot, category: defaultCategory as string, message: '' }); setTimeout(() => setStatus('idle'), 4500); } else { setStatus('error'); setTimeout(() => setStatus('idle'), 4500); } } catch { setStatus('error'); setTimeout(() => setStatus('idle'), 4500); } }; const field: React.CSSProperties = { width: '100%', padding: '0.875rem 1rem', borderRadius: '0.75rem', border: '1px solid rgba(94, 94, 94, 0.18)', background: 'rgba(15, 12, 8,0.55)', color: '#fcfcfc', fontSize: '0.95rem', outline: 'none', boxSizing: 'border-box', transition: 'border-color 0.2s, background 0.2s', fontFamily: 'inherit', }; const label: React.CSSProperties = { fontSize: '0.72rem', letterSpacing: '0.18em', textTransform: 'uppercase', color: '#a8a8a8', fontWeight: 600, }; return (
{status === 'success' && (
Thank you your message was sent. Our team will reach out shortly.
)} {status === 'error' && (
Something went wrong. Please try again, or email info@yslootahrobotics.com.
)}
setData({ ...data, name: e.target.value })} placeholder="Your name" />
setData({ ...data, company: e.target.value })} placeholder="Company or organization" />
setData({ ...data, email: e.target.value })} placeholder="you@company.com" />
setData({ ...data, phone: e.target.value })} placeholder="+971 …" />
setData({ ...data, robotInterest: e.target.value })} placeholder="e.g. Unitree Go2, BellaBot" />