import { SubmitHandler, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { LuChevronRight } from "react-icons/lu"; import Button from "@/lib/components/ui/Button"; import Spinner from "@/lib/components/ui/Spinner"; import { emailPattern } from "@/lib/config/patterns"; import { usePostContactSales } from "../hooks/usePostContactSales"; export const ContactForm = (): JSX.Element => { const { t } = useTranslation("contact", { keyPrefix: "form" }); const { register, handleSubmit, formState } = useForm({ defaultValues: { email: "", message: "" }, }); const postEmail = usePostContactSales(); const onSubmit: SubmitHandler<{ email: string; message: string }> = ( data, event ) => { event?.preventDefault(); postEmail.mutate({ customer_email: data.email, content: data.message, }); }; if (postEmail.isSuccess) { return (

{t("thank_you")}

{t("thank_you_text")}

); } if (postEmail.isPending) { return ; } return (
void handleSubmit(onSubmit)(event)} >
); };