soul-speaks-soil-website/components/contact-form.tsx

99 lines
3.2 KiB
TypeScript

"use client"
import type React from "react"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Send } from "lucide-react"
export function ContactForm() {
const [isSubmitting, setIsSubmitting] = useState(false)
const [isSubmitted, setIsSubmitted] = useState(false)
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
setIsSubmitting(true)
// Simulate form submission
await new Promise((resolve) => setTimeout(resolve, 1500))
setIsSubmitting(false)
setIsSubmitted(true)
// Reset form after 3 seconds
setTimeout(() => {
setIsSubmitted(false)
;(e.target as HTMLFormElement).reset()
}, 3000)
}
return (
<form onSubmit={handleSubmit} className="space-y-6">
<div className="grid sm:grid-cols-2 gap-6">
<div className="space-y-2">
<Label htmlFor="firstName">First Name</Label>
<Input id="firstName" name="firstName" placeholder="John" required disabled={isSubmitting} />
</div>
<div className="space-y-2">
<Label htmlFor="lastName">Last Name</Label>
<Input id="lastName" name="lastName" placeholder="Doe" required disabled={isSubmitting} />
</div>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input id="email" name="email" type="email" placeholder="john@example.com" required disabled={isSubmitting} />
</div>
<div className="space-y-2">
<Label htmlFor="inquiryType">Inquiry Type</Label>
<Select name="inquiryType" required disabled={isSubmitting}>
<SelectTrigger id="inquiryType">
<SelectValue placeholder="Select an option" />
</SelectTrigger>
<SelectContent>
<SelectItem value="consulting">Consulting</SelectItem>
<SelectItem value="podcast-guest">Podcast Guest Appearance</SelectItem>
<SelectItem value="speaking">Speaking Engagement</SelectItem>
<SelectItem value="collaboration">Collaboration</SelectItem>
<SelectItem value="other">Other</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="message">Message</Label>
<Textarea
id="message"
name="message"
placeholder="Tell me about your inquiry..."
rows={6}
required
disabled={isSubmitting}
/>
</div>
<Button type="submit" size="lg" className="w-full" disabled={isSubmitting}>
{isSubmitting ? (
"Sending..."
) : isSubmitted ? (
"Message Sent!"
) : (
<>
<Send className="mr-2 h-4 w-4" />
Send Message
</>
)}
</Button>
{isSubmitted && (
<p className="text-center text-sm text-primary">Thank you for reaching out! I'll get back to you soon.</p>
)}
</form>
)
}