-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dev-portfolio
- Loading branch information
Showing
11 changed files
with
280 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# Google Sheets | ||
GOOGLE_CLIENT_EMAIL= | ||
GOOGLE_PRIVATE_KEY= | ||
GOOGLE_SHEET_ID= | ||
|
||
# Google reCAPTCHA | ||
NEXT_PUBLIC_GOOGLE_RECAPTCHA= | ||
GOOGLE_RECAPTCHA= | ||
|
||
# Google Maps | ||
NEXT_PUBLIC_GOOGLE_MAPS_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": [ | ||
"development" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
|
||
"use client"; | ||
|
||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Textarea } from "@/components/ui/textarea"; | ||
import { useForm } from "react-hook-form"; | ||
import ReCAPTCHA from "react-google-recaptcha"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { z } from "zod"; | ||
import { env } from "@/env"; | ||
|
||
const formSchema = z.object({ | ||
nome: z.string().min(1, { message: "Nome é obrigatório" }), | ||
email: z.string().email({ message: "Email inválido" }), | ||
mensagem: z.string().min(1, { message: "Mensagem é obrigatória" }), | ||
reCAPTCHA: z.boolean().refine((value) => value === true, { | ||
message: "Confirme que você não é um robô", | ||
}), | ||
}); | ||
|
||
type FormSchemaType = z.infer<typeof formSchema>; | ||
|
||
export function ContactForm() { | ||
const form = useForm<FormSchemaType>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
nome: "", | ||
email: "", | ||
mensagem: "", | ||
reCAPTCHA: false, | ||
}, | ||
}); | ||
|
||
const onSubmit = (data: FormSchemaType) => { | ||
console.log(data); | ||
// Limpar os campos do formulário após o envio | ||
form.reset(); | ||
}; | ||
return ( | ||
<Form {...form}> | ||
<form | ||
onSubmit={form.handleSubmit(onSubmit)} | ||
className="mt-4 flex w-full flex-col space-y-8 font-secondary text-black-600" | ||
> | ||
<FormField | ||
control={form.control} | ||
name="nome" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<Input | ||
placeholder="Nome" | ||
{...field} | ||
className="h-14 rounded-xl border-solid border-gray-300 text-base font-medium shadow-md shadow-black-400 drop-shadow-xl placeholder:text-gray-600" | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<Input | ||
placeholder="E-mail" | ||
{...field} | ||
className="h-14 rounded-xl border-solid border-gray-300 text-base font-medium shadow-md shadow-black-400 drop-shadow-xl placeholder:text-gray-600" | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="mensagem" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<Textarea | ||
placeholder="Sua mensagem" | ||
{...field} | ||
className="h-40 w-full resize-none rounded-xl border-solid border-gray-300 p-2 text-base font-medium shadow-md shadow-black-400 drop-shadow-xl placeholder:text-gray-600" | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<div className="flex items-start justify-between align-middle"> | ||
<FormField | ||
control={form.control} | ||
name="reCAPTCHA" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<ReCAPTCHA | ||
sitekey={env.NEXT_PUBLIC_GOOGLE_RECAPTCHA} | ||
onChange={() => field.onChange(true)} | ||
onExpired={() => field.onChange(false)} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button | ||
className="my-auto h-10 w-28 self-end bg-blue-900 text-lg shadow-xl drop-shadow-xl" | ||
type="submit" | ||
> | ||
Enviar | ||
</Button> | ||
</div> | ||
</form> | ||
</Form> | ||
); | ||
} |
Oops, something went wrong.