diff --git a/package.json b/package.json index 8b804ba..49dcd78 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,10 @@ "check": "npx @biomejs/biome check ./" }, "dependencies": { + "@hookform/resolvers": "^3.10.0", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", + "@radix-ui/react-label": "^2.1.1", "@radix-ui/react-separator": "^1.1.1", "@radix-ui/react-slot": "^1.1.1", "@vercel/analytics": "^1.4.1", @@ -43,9 +45,11 @@ "next-themes": "^0.4.4", "react": "^19.0.0", "react-dom": "^19.0.0", + "react-hook-form": "^7.54.2", "simple-icons": "^14.2.0", "tailwind-merge": "^2.6.0", - "tailwindcss-animate": "^1.0.7" + "tailwindcss-animate": "^1.0.7", + "zod": "^3.24.1" }, "devDependencies": { "@biomejs/biome": "^1.9.4", diff --git a/public/locales/en-US.json b/public/locales/en-US.json index bfbdcfd..1ca8af6 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -125,6 +125,19 @@ "Description": "Configuring a linter and formatter, such as BiomeJS, is crucial for maintaining consistent, readable, and error-free code. Linters ensure uniform coding standards and early error detection, saving debugging time. Formatters automate code structuring, enhancing readability and maintenance. These tools increase productivity by allowing developers to focus on critical tasks. They also enforce quality standards, creating a professional development environment. In CI/CD workflows, they ensure code adherence to quality standards, preserving codebase integrity." } }, + "Contact": { + "Title": "Contact", + "Form": { + "Name": "Name", + "NameDescription": "What should I call you?", + "Subject": "Subject", + "SubjectDescription": "What would you like to talk about?", + "Message": "Message", + "MessageDescription": "Write your message here...", + "Submit": "Submit", + "NameTooShort": "Name must have at least 3 characters" + } + }, "Error": { "Copy": "Copy", "Reload": "Click here to back to main page", diff --git a/public/locales/pt-BR.json b/public/locales/pt-BR.json index 5e3c75b..44068dc 100644 --- a/public/locales/pt-BR.json +++ b/public/locales/pt-BR.json @@ -125,6 +125,19 @@ "Description": "Configurar um linter e um formatador, como o BiomeJS, é essencial para manter um código consistente, legível e livre de erros. Linters garantem padrões uniformes de codificação e a detecção precoce de erros, economizando tempo de depuração. Formatadores automatizam a estruturação do código, melhorando sua legibilidade e manutenção. Essas ferramentas aumentam a produtividade, permitindo que os desenvolvedores se concentrem em tarefas críticas. Além disso, elas reforçam padrões de qualidade, criando um ambiente de desenvolvimento profissional. Em fluxos de trabalho CI/CD, garantem a conformidade do código com os padrões de qualidade, preservando a integridade da base de código." } }, + "Contact": { + "Title": "Contato", + "Form": { + "Name": "Nome", + "NameDescription": "Como posso te chamar?", + "Subject": "Assunto", + "SubjectDescription": "Sobre o que você gostaria de falar?", + "Message": "Mensagem", + "MessageDescription": "Escreva sua mensagem aqui...", + "Submit": "Enviar", + "NameTooShort": "Nome deve ter no mínimo 3 caracteres" + } + }, "Error": { "Copy": "Copiar", "Reload": "Clique aqui para voltar para a página principal", diff --git a/src/components/contact.tsx b/src/components/contact.tsx index 4931f5a..4d3b41b 100644 --- a/src/components/contact.tsx +++ b/src/components/contact.tsx @@ -1,3 +1,115 @@ +"use client"; + +import { useTranslations } from "next-intl"; +import { z } from "zod"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; + +import { + Button, + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, + Input, + Textarea, +} from "@/components/ui"; + export function Contact() { - return
; + const t = useTranslations("Contact"); + + const formSchema = z.object({ + name: z + .string() + .min(3, { + message: t("Form.NameTooShort"), + }) + .nonempty({}), + subject: z.string().nonempty(), + message: z.string().nonempty(), + }); + + type formType = z.infer; + + const form = useForm({ + resolver: zodResolver(formSchema), + defaultValues: { + name: "", + subject: "", + message: "", + }, + }); + + function onSubmit(values: formType) { + const { name, subject, message } = values; + + const body = `Name: ${name}\n\nMessage: ${message}`; + + const mailtoLink = `mailto:nedcloar1@hotmail.com?subject=${subject}&body=${body}`; + window.open(mailtoLink, "_blank"); + } + + return ( +
+

+ {t("Title")} +

+
+
+ + ( + + {t("Form.Name")} + + + + {t("Form.NameDescription")} + + + )} + /> + ( + + {t("Form.Subject")} + + + + + {t("Form.SubjectDescription")} + + + + )} + /> + ( + + {t("Form.Message")} + +