update superpage

This commit is contained in:
2025-04-15 19:07:36 -03:00
parent 27769ba363
commit c702ca870b
24 changed files with 538 additions and 605 deletions

View File

@@ -1,33 +1,33 @@
import { useForm } from "react-hook-form";
import { useMutation } from "node_modules/@tanstack/react-query/build/legacy";
import { queryClient } from "../queryClient";
import axios from "axios";
import { createElement } from "react";
import clsx from "clsx";
import { useForm } from 'react-hook-form'
import { useMutation } from 'node_modules/@tanstack/react-query/build/legacy'
import { queryClient } from '../queryClient'
import axios from 'axios'
import { createElement } from 'react'
import clsx from 'clsx'
interface IFormInput {
name: string;
email: string;
message: string;
name: string
email: string
message: string
}
export function Form() {
const { register, handleSubmit, reset, formState } = useForm<IFormInput>();
const { register, handleSubmit, reset, formState } = useForm<IFormInput>()
const { mutateAsync } = useMutation(
{
mutationFn: async (data: IFormInput) => {
return await axios.post("https://n8n.sergio.run/webhook/eduseg", data);
return await axios.post('https://n8n.sergio.run/webhook/eduseg', data)
},
onSuccess: () => {
reset();
reset()
},
},
queryClient,
);
)
const onSubmit = async (data: IFormInput) => {
await mutateAsync(data);
};
await mutateAsync(data)
}
return (
<form
@@ -41,17 +41,17 @@ export function Form() {
<div className="grid lg:grid-cols-2 gap-3 lg:gap-6">
<label>
Nome
<Input {...register("name")} />
<Input {...register('name')} />
</label>
<label>
Email
<Input {...register("email")} />
<Input {...register('email')} />
</label>
</div>
<label>
Mensagem
<Input as="textarea" className="h-26" {...register("message")} />
<Input as="textarea" className="h-26" {...register('message')} />
</label>
<button
@@ -61,20 +61,20 @@ export function Form() {
Quero um orçamento
</button>
</form>
);
)
}
interface IInput extends React.HTMLAttributes<HTMLElement> {
as?: string;
className?: string | undefined;
as?: string
className?: string | undefined
}
export function Input({ as = "input", className, ...props }: IInput) {
export function Input({ as = 'input', className, ...props }: IInput) {
return createElement(as, {
className: clsx(
"border border-transparent focus:border-green-secondary focus:ring ring-green-secondary text-white bg-black p-3 rounded-lg w-full outline-none",
'border border-transparent focus:border-green-secondary focus:ring ring-green-secondary text-white bg-black p-3 rounded-lg w-full outline-none',
className,
),
...props,
});
})
}