From e829451fa388ced43b9b74a77580cf1e126895be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Fri, 13 Feb 2026 14:31:21 +0800 Subject: [PATCH] fix: resolve TypeScript errors for Zod v4 API changes --- src/components/sections/contact-section.tsx | 11 +++++++---- src/components/sections/insights-section.tsx | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/sections/contact-section.tsx b/src/components/sections/contact-section.tsx index 580da36..82ed505 100644 --- a/src/components/sections/contact-section.tsx +++ b/src/components/sections/contact-section.tsx @@ -60,7 +60,10 @@ export function ContactSection() { setErrors((prev) => ({ ...prev, [field]: undefined })); } catch (error) { if (error instanceof z.ZodError) { - setErrors((prev) => ({ ...prev, [field]: error.errors[0].message })); + const fieldError = error.issues[0]; + if (fieldError) { + setErrors((prev) => ({ ...prev, [field]: fieldError.message })); + } } } }; @@ -83,9 +86,9 @@ export function ContactSection() { if (!result.success) { const fieldErrors: FormErrors = {}; - result.error.errors.forEach((error) => { - const field = error.path[0] as keyof ContactFormData; - fieldErrors[field] = error.message; + result.error.issues.forEach((issue) => { + const field = issue.path[0] as keyof ContactFormData; + fieldErrors[field] = issue.message; }); setErrors(fieldErrors); return; diff --git a/src/components/sections/insights-section.tsx b/src/components/sections/insights-section.tsx index d59662c..a2cca1c 100644 --- a/src/components/sections/insights-section.tsx +++ b/src/components/sections/insights-section.tsx @@ -114,7 +114,7 @@ export function InsightsSection() { `} >