33import { AcceptTermsCheckbox } from "@/components/AcceptTermsCheckbox"
44import type { AppLocale } from "@/lib/i18n"
55import { Button , EmailInput , emailValidation , TextAreaInput , TextInput , useForm } from "@code0-tech/pictor"
6+ import type { FocusEvent } from "react"
67import { useMemo , useState } from "react"
78import { useWebHaptics } from "web-haptics/react"
89
910interface ContactFormContent {
10- heading : string
1111 nameLabel : string
1212 namePlaceholder : string
1313 emailLabel : string
@@ -22,8 +22,14 @@ interface ContactFormProps {
2222 locale : AppLocale
2323}
2424
25+ interface ContactFormValues {
26+ name : string
27+ email : string
28+ message : string
29+ acceptTerms : boolean
30+ }
31+
2532const defaultContent : ContactFormContent = {
26- heading : "Contact us" ,
2733 nameLabel : "Name" ,
2834 namePlaceholder : "Your name" ,
2935 emailLabel : "Email" ,
@@ -39,7 +45,7 @@ export function ContactForm({ content, locale }: ContactFormProps) {
3945
4046 const [ isSubmitting , setIsSubmitting ] = useState ( false )
4147 const [ submitStatus , setSubmitStatus ] = useState < { type : "success" | "error" , message : string } | null > ( null )
42- const initialValues = useMemo ( ( ) => ( {
48+ const initialValues = useMemo < ContactFormValues > ( ( ) => ( {
4349 name : "" ,
4450 email : "" ,
4551 message : "" ,
@@ -70,7 +76,7 @@ export function ContactForm({ content, locale }: ContactFormProps) {
7076 useInitialValidation : false ,
7177 initialValues,
7278 validate : validation ,
73- onSubmit : ( values ) => {
79+ onSubmit : ( values : ContactFormValues ) => {
7480 if ( isSubmitting ) return
7581
7682 setIsSubmitting ( true )
@@ -115,7 +121,6 @@ export function ContactForm({ content, locale }: ContactFormProps) {
115121
116122 return (
117123 < div className = "flex flex-col gap-4" >
118- < h1 className = "text-4xl font-semibold text-white" > { labels . heading } </ h1 >
119124 < div className = "flex flex-col gap-2 mt-6" >
120125 < TextInput
121126 placeholder = { labels . namePlaceholder }
@@ -137,7 +142,7 @@ export function ContactForm({ content, locale }: ContactFormProps) {
137142 validate ( "email" )
138143 }
139144 } }
140- onBlur = { ( event ) => {
145+ onBlur = { ( event : FocusEvent < HTMLInputElement > ) => {
141146 const value = event . currentTarget . value ?. trim ( )
142147 if ( value && ! emailValidation ( value ) ) {
143148 validate ( "email" )
0 commit comments