'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 talk
strategy.

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.

) : (

Send us a message

{formState === 'error' && (
{errorMessage}
)}