'use client'; import { useState, FormEvent } from 'react'; type FormState = 'idle' | 'sending' | 'success' | 'error'; const DETAILS = [ { label: 'Visit us', value: <>No.424, Red Rose Towers,DB Road, RS Puram,Coimbatore – 641002>, icon: ( ), }, { label: 'Email us', value: loyalydigital@gmail.com, icon: ( ), }, ]; const SOCIALS = [ { label: 'LinkedIn', href: 'https://www.linkedin.com/company/loyaly-ai', icon: }, { label: 'X / Twitter', href: 'https://twitter.com/loyalyai', icon: }, { label: 'Instagram', href: 'https://instagram.com/loyalyai', icon: }, ]; export default function GetInTouch() { const [formState, setFormState] = useState('idle'); const [errorMessage, setErrorMessage] = useState(''); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setFormState('sending'); setErrorMessage(''); const form = e.currentTarget; const data = { name: (form.elements.namedItem('name') as HTMLInputElement).value, email: (form.elements.namedItem('email') as HTMLInputElement).value, subject: (form.elements.namedItem('subject') as HTMLInputElement).value, message: (form.elements.namedItem('message') as HTMLTextAreaElement).value, }; try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); if (!res.ok) { const body = await res.json().catch(() => ({})); throw new Error(body.message || `Request failed: ${res.status}`); } setFormState('success'); form.reset(); } catch (err) { setFormState('error'); setErrorMessage(err instanceof Error ? err.message : 'Something went wrong. Please try again.'); } }; return ( {/* ── Left — info ── */} Get in Touch Let's talkstrategy. Whether you're exploring AI possibilities or ready to deploy, our team will help you find the right solution for your business. {/* Detail cards */} {DETAILS.map((d) => ( {d.icon} {d.label} {d.value} ))} {/* Socials */} Follow {SOCIALS.map((s) => ( {s.icon} ))} {/* ── Right — form ── */} {formState === 'success' ? ( Message sent! We'll get back to you within one business day. setFormState('idle')} style={{ marginTop: 28, padding: '12px 28px', borderRadius: 100, background: 'transparent', border: '1px solid rgba(255,255,255,0.2)', color: '#fff', fontWeight: 600, fontSize: 14, cursor: 'pointer', fontFamily: 'Sora, sans-serif', }}>Send another message ) : ( Send us a message {formState === 'error' && ( {errorMessage} )} Full Name Email Address * Subject Message {formState === 'sending' ? ( <> Sending… > ) : ( <>Send Message > )} )} ); } const labelStyle: React.CSSProperties = { display: 'flex', flexDirection: 'column', gap: 8, fontSize: 13, fontWeight: 600, color: 'rgba(255,255,255,0.55)', fontFamily: 'Sora, sans-serif', }; const inputStyle: React.CSSProperties = { padding: '13px 16px', border: '1px solid rgba(255,255,255,0.1)', borderRadius: 12, fontSize: 15, background: 'rgba(255,255,255,0.04)', color: '#fff', outline: 'none', width: '100%', boxSizing: 'border-box', fontFamily: 'Sora, sans-serif', transition: 'border-color 0.2s ease, box-shadow 0.2s ease', };
Whether you're exploring AI possibilities or ready to deploy, our team will help you find the right solution for your business.
We'll get back to you within one business day.