Overview
TheContactForm component is a client-side form that allows users to contact Product Builders. It includes fields for email, service selection, and a message. The form uses React Hook Form for validation, Zod for schema validation, and Next.js server actions for submission.
This is a client component (marked with "use client") that integrates with the shadcn/ui form components and provides real-time validation feedback.
Component Structure
Usage Example
The ContactForm is typically used within the CtaSection component, but can be used standalone:Props
Form Fields
The contact form includes three fields:Email Field
- Label: “Email”
- Placeholder: “[email protected]”
- Validation: Must be a valid email address
- Error Message: “Por favor, introduce un email válido.”
Service Selection
- Label: “Servicio de interés”
- Placeholder: “Selecciona un servicio”
- Options: Populated from the
offeringsprop - Validation: Required field
- Error Message: “Por favor, selecciona un servicio.”
Message Field
- Label: “Mensaje”
- Placeholder: “Cuéntanos un poco sobre tu proyecto…”
- Type: Textarea (multi-line input)
- Validation: Minimum 10 characters
- Error Message: “El mensaje debe tener al menos 10 caracteres.”
Validation Schema
The form uses Zod for validation:Features
- Client-Side Validation: Real-time validation using React Hook Form and Zod
- Server Actions: Submits to
submitContactFormserver action from@/app/actions - Toast Notifications: Shows success or error messages using the toast hook
- Form Reset: Automatically resets form fields after successful submission
- Loading State: Submit button shows “Enviando…” while pending
- Disabled State: Submit button is disabled during submission
- Form State Management: Uses
useActionStateto track server response
Submit Button Component
The form includes an internalSubmitButton component that handles the pending state:
Toast Integration
The component uses theuseToast hook to display notifications:
Customization
All user-facing text is defined in thecontactTexts object (lines 31-50):
Styling
- Card with semi-transparent white background and backdrop blur
- Maximum width of
max-w-lg(32rem) - Full-width submit button
- White input backgrounds for better contrast
- Responsive spacing with
space-y-6between fields