diff --git a/src/components/sections/contact/ContactSplitForm.tsx b/src/components/sections/contact/ContactSplitForm.tsx index 1157daf..15ed065 100644 --- a/src/components/sections/contact/ContactSplitForm.tsx +++ b/src/components/sections/contact/ContactSplitForm.tsx @@ -1,81 +1,214 @@ "use client"; -import React, { useState } from "react"; +import { useState } from "react"; +import TextAnimation from "@/components/text/TextAnimation"; +import Button from "@/components/button/Button"; +import Input from "@/components/form/Input"; +import Textarea from "@/components/form/Textarea"; +import MediaContent from "@/components/shared/MediaContent"; +import { cls, shouldUseInvertedText } from "@/lib/utils"; +import { useTheme } from "@/providers/themeProvider/ThemeProvider"; +import { useButtonAnimation } from "@/components/hooks/useButtonAnimation"; +import { getButtonProps } from "@/lib/buttonUtils"; +import type { AnimationType } from "@/components/text/types"; +import type { ButtonAnimationType } from "@/types/button"; +import {sendContactEmail} from "@/utils/sendContactEmail"; -interface ContactSplitFormProps { - tag: string; - title: string; - description: string; - formFields?: Array<{ name: string; label: string; type: string; required?: boolean }>; - buttonText?: string; - className?: string; +export interface InputField { + name: string; + type: string; + placeholder: string; + required?: boolean; + className?: string; } -const ContactSplitForm: React.FC = ({ - tag, - title, - description, - formFields = [ - { name: "name", label: "Name", type: "text", required: true }, - { name: "email", label: "Email", type: "email", required: true }, - { name: "message", label: "Message", type: "textarea", required: true }, - ], - buttonText = "Send", className = ""}) => { - const [formData, setFormData] = useState>({}); +export interface TextareaField { + name: string; + placeholder: string; + rows?: number; + required?: boolean; + className?: string; +} - const handleChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData((prev) => ({ ...prev, [name]: value })); - }; +interface ContactSplitFormProps { + title: string; + description: string; + inputs: InputField[]; + textarea?: TextareaField; + useInvertedBackground: boolean; + imageSrc?: string; + videoSrc?: string; + imageAlt?: string; + videoAriaLabel?: string; + mediaPosition?: "left" | "right"; + mediaAnimation: ButtonAnimationType; + buttonText?: string; + onSubmit?: (data: Record) => void; + ariaLabel?: string; + className?: string; + containerClassName?: string; + contentClassName?: string; + formCardClassName?: string; + titleClassName?: string; + descriptionClassName?: string; + buttonClassName?: string; + buttonTextClassName?: string; + mediaWrapperClassName?: string; + mediaClassName?: string; +} - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - console.log("Form submitted:", formData); - setFormData({}); - }; +const ContactSplitForm = ({ + title, + description, + inputs, + textarea, + useInvertedBackground, + imageSrc, + videoSrc, + imageAlt = "", + videoAriaLabel = "Contact section video", + mediaPosition = "right", + mediaAnimation, + buttonText = "Submit", + onSubmit, + ariaLabel = "Contact section", + className = "", + containerClassName = "", + contentClassName = "", + formCardClassName = "", + titleClassName = "", + descriptionClassName = "", + buttonClassName = "", + buttonTextClassName = "", + mediaWrapperClassName = "", + mediaClassName = "", +}: ContactSplitFormProps) => { + const theme = useTheme(); + const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle); + const { containerRef: mediaContainerRef } = useButtonAnimation({ animationType: mediaAnimation }); - return ( -
-
-
{tag}
-

{title}

-

{description}

+ // Validate minimum inputs requirement + if (inputs.length < 2) { + throw new Error("ContactSplitForm requires at least 2 inputs"); + } -
- {formFields.map((field) => ( -
- - {field.type === "textarea" ? ( -