diff --git a/src/app/contributors/ContributorsData.ts b/src/app/contributors/ContributorsData.ts index 64fa6ed..b8537f8 100644 --- a/src/app/contributors/ContributorsData.ts +++ b/src/app/contributors/ContributorsData.ts @@ -140,4 +140,9 @@ export const ContributorsData = [ github: "https://github.com/RamakrushnaBiswal", imageUrl: "https://avatars.githubusercontent.com/u/125277258?v=4", }, + { + name: "Akhila Sunesh", + github: "https://github.com/AkhilaSunesh", + imageUrl: "https://avatars.githubusercontent.com/u/140897461?s=400&v=4", + }, ]; diff --git a/src/components/shared/customerreviews.tsx b/src/components/shared/customerreviews.tsx index 6d6a188..aee5169 100644 --- a/src/components/shared/customerreviews.tsx +++ b/src/components/shared/customerreviews.tsx @@ -3,7 +3,7 @@ import * as React from "react"; import * as z from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import emailjs from "emailjs-com"; +import emailjs from '@emailjs/browser'; import { Form, FormControl, @@ -52,41 +52,41 @@ const formSchema = z.object({ name: z.string().nonempty("Name is required"), email: z.string().email("Invalid email address"), feedback: z.string().nonempty("Feedback is required"), + feedbackType: z.string().nonempty("Feedback type is required"), + otherFeedback: z.string().optional(), }); -export function TextareaForm() { - const form = useForm>({ - resolver: zodResolver(formSchema), - }); -} - export default function Review() { - const [acknowledgment, setAcknowledgment] = React.useState(""); + const [showOtherFeedback, setShowOtherFeedback] = React.useState(false); + const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { name: "", email: "", feedback: "", + feedbackType: "", + otherFeedback: "", }, }); - const handleSubmit = async (values: z.infer) => { + const handleFeedbackTypeChange = (value: string) => { + setShowOtherFeedback(value === "Other"); + }; + + const onSubmit = async (values: z.infer) => { try { await emailjs.send( process.env.NEXT_PUBLIC_EMAILJS_SERVICE_ID!, process.env.NEXT_PUBLIC_EMAILJS_TEMPLATE_ID!, - { - from_name: values.name, - to_name: "Blox AI", // Replace with the recipient's name or a variable - message: values.feedback, - }, + values, process.env.NEXT_PUBLIC_EMAILJS_API_KEY! ); - setAcknowledgment("Thank you! Your review has been received."); + alert("Thank you! Your review has been received."); form.reset(); } catch (error) { console.error("Failed to send feedback:", error); + alert("Failed to send feedback. Please try again later."); } }; @@ -107,18 +107,9 @@ export default function Review() {

- {acknowledgment && ( -
- {acknowledgment} -
- )}
{ - handleSubmit(values); - }) - } + onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-8" > + ( + + Feedback Type + + + + + + )} + /> + + {showOtherFeedback && ( + ( + + Other Feedback + + + + + + )} + /> + )} +