"use client"; import Iconss from "@/components/ui/icons"; import { Mail, Send, WebhookIcon, Bug, Shield } from "lucide-react"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { contactFormSchema } from "@/lib/validations/validation"; import { Button } from "@/components/ui/button"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { useToast } from "@/components/ui/use-toast"; import { useState } from "react"; const ContactUs = () => { const { toast } = useToast(); const [loading, setLoading] = useState(false); const form = useForm>({ resolver: zodResolver(contactFormSchema), defaultValues: { name: "", email: "", message: "", }, }); async function onSubmit(values: z.infer) { setLoading(true); try { const res = await fetch("/api/contact", { method: "POST", body: JSON.stringify(values), headers: { "Content-Type": "application/json", Accept: "application/json", }, }); if (res.ok) { form.reset(); toast({ description: "Your message has been sent.", }); setLoading(false); } else { toast({ title: "Uh oh! Something went wrong.", variant: "destructive", }); setLoading(false); } } catch (error) { console.error(error); toast({ title: "Uh oh! Something went wrong.", variant: "destructive", }); setLoading(false); } console.log(values); } return ( <>

Contact Us

{/* Left contact page */}
( Name )} /> ( Email )} /> ( Message