import React, { useState } from 'react'; import { CheckIcon } from './ReactIcons/CheckIcon.tsx'; import { pageProgressMessage } from '../stores/page.ts'; import { httpPost } from '../lib/http.ts'; type InputProps = { label: string; name: string; type: string; value: string; onChange: ( e: React.ChangeEvent, ) => void; required?: boolean; rows?: number; }; function Input(props: InputProps) { const { label, name, type, value, onChange, required, rows } = props; return (
{type === 'textarea' ? ( ) : ( )}
); } export function AdvertiseForm() { const [status, setStatus] = useState<'submitting' | 'submitted'>(); const [error, setError] = useState(null); const [formData, setFormData] = useState({ firstName: '', lastName: '', title: '', company: '', email: '', phone: '', message: '', updates: false, }); const handleInputChange = ( e: React.ChangeEvent, ) => { const { name, value, type, checked } = e.target as any; setFormData({ ...formData, [name]: type === 'checkbox' ? checked : value, }); }; async function handleSubmit(e: React.FormEvent) { e.preventDefault(); pageProgressMessage.set('Please wait'); // Placeholder function to send data console.log('Form data:', formData); const { response, error } = await httpPost( `${import.meta.env.PUBLIC_API_URL}/v1-advertise`, formData, ); if (!response || error) { pageProgressMessage.set(''); setError(error?.message || 'Something went wrong. Please try again.'); return; } setStatus('submitted'); pageProgressMessage.set(''); } if (status === 'submitted') { return (

Thank you for your interest in advertising with roadmap.sh

We will get back to you soon.

); } return ( <>

Ready to learn more? Fill out the form below to get started!

{error && (
{error}
)}
); }