mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-03 13:06:37 -04:00
fix eslint 9 problems, especially in vs code
This commit is contained in:
@ -20,10 +20,10 @@ export async function sendMessage(
|
||||
success: boolean;
|
||||
message: string;
|
||||
errors?: z.inferFormattedError<typeof schema>;
|
||||
payload: FormData;
|
||||
payload?: FormData;
|
||||
}> {
|
||||
try {
|
||||
const validatedFields = schema.safeParse({ ...formData });
|
||||
const validatedFields = schema.safeParse(Object.fromEntries(formData));
|
||||
|
||||
// backup to client-side validations just in case someone squeezes through without them
|
||||
if (!validatedFields.success) {
|
||||
@ -47,7 +47,13 @@ export async function sendMessage(
|
||||
remoteip: (await headers()).get("x-forwarded-for") || "",
|
||||
}),
|
||||
cache: "no-store",
|
||||
signal: AbortSignal.timeout(5000), // 5 second timeout
|
||||
});
|
||||
|
||||
if (!turnstileResponse.ok) {
|
||||
throw new Error(`Turnstile validation failed: ${turnstileResponse.status}`);
|
||||
}
|
||||
|
||||
const turnstileData = await turnstileResponse?.json();
|
||||
|
||||
if (!turnstileData?.success) {
|
||||
@ -70,7 +76,7 @@ export async function sendMessage(
|
||||
|
||||
return { success: true, message: "Thanks! You should hear from me soon.", payload: formData };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error("Contact form error:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
|
@ -12,9 +12,9 @@ import { SiMarkdown } from "react-icons/si";
|
||||
import styles from "./form.module.css";
|
||||
|
||||
const ContactForm = () => {
|
||||
const [formState, formAction, pending] = useActionState<Partial<Awaited<ReturnType<typeof sendMessage>>>, FormData>(
|
||||
const [formState, formAction, pending] = useActionState<Awaited<ReturnType<typeof sendMessage>>, FormData>(
|
||||
sendMessage,
|
||||
{}
|
||||
{ success: false, message: "" }
|
||||
);
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user