"use client"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; const formSchema = z.object({ firstname: z.string().min(2, { message: "Prénom trop court" }), lastname: z.string().min(2, { message: "Nom trop court" }), phone: z .string() .min(10, { message: "Un numéro de téléphone à 10 chiffres" }), email: z.string().email({ message: "Invalid email address" }), message: z .string() .min(10, { message: "Message must be at least 10 characters long" }), }); export default function ContactFormPreview() { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { firstname: "", lastname: "", phone: "", email: "", }, }); async function onSubmit(values: z.infer) { try { console.log(values); await fetch("/api/users/new", { method: "POST", body: JSON.stringify(values), }); } catch (error) { console.error("Form submission error", error); } console.log("subimted"); } return (
Contact Us Please fill out the form below and we will get back to you shortly.
{/* Firstname Field */} ( Prénom )} />
{/* Firstname Field */} ( Nom )} /> {/* Email Field */} ( Email )} /> {/* Message Field */} ( Phone number )} />
); }