@@ -19,7 +19,10 @@ import { Textarea } from "@/components/ui/textarea"; // For body field
1919
2020// Define the Zod schema as the primary source of truth for the form's shape
2121const emailDialogZodSchema = z . object ( {
22- from : z . string ( ) . email ( { message : "Invalid email address for From field." } ) . min ( 1 , { message : "From is required." } ) ,
22+ from : z
23+ . string ( )
24+ . email ( { message : "Invalid email address for From field." } )
25+ . min ( 1 , { message : "From is required." } ) ,
2326 subject : z . string ( ) . min ( 1 , { message : "Subject is required." } ) ,
2427 body : z . string ( ) . min ( 1 , { message : "Body is required." } ) ,
2528} ) ;
@@ -41,7 +44,6 @@ type Assert<T, U extends T> = U;
4144type _SchemaMatchesData = Assert < EmailData , EmailDialogFormShape > ;
4245type _DataMatchesSchema = Assert < EmailDialogFormShape , EmailData > ;
4346
44-
4547type EmailDialogProps = {
4648 isOpen : boolean ;
4749 onClose : ( ) => void ;
@@ -61,7 +63,8 @@ export function EmailDialog({
6163 handleSubmit,
6264 reset,
6365 formState : { errors, isDirty, isValid } ,
64- } = useForm < EmailDialogFormShape > ( { // Use the inferred type from the Zod schema
66+ } = useForm < EmailDialogFormShape > ( {
67+ // Use the inferred type from the Zod schema
6568 resolver : zodResolver ( emailDialogZodSchema ) , // Use the Zod schema directly
6669 mode : "onChange" ,
6770 defaultValues : {
@@ -97,18 +100,25 @@ export function EmailDialog({
97100 < AlertDialogHeader >
98101 < AlertDialogTitle > Simulate Email Trigger</ AlertDialogTitle >
99102 < AlertDialogDescription >
100- Fill in the details below to simulate sending an email. This will trigger the workflow.
103+ Fill in the details below to simulate sending an email. This will
104+ trigger the workflow.
101105 </ AlertDialogDescription >
102106 </ AlertDialogHeader >
103107 < form onSubmit = { handleSubmit ( processSubmit ) } id = "emailTriggerForm" >
104108 < div className = "space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-2" >
105109 < div >
106- < Label htmlFor = "from" > From < span className = "text-destructive font-medium" > *</ span > </ Label >
110+ < Label htmlFor = "from" >
111+ From < span className = "text-destructive font-medium" > *</ span >
112+ </ Label >
107113 < Controller
108114 name = "from"
109115 control = { control }
110116 render = { ( { field } ) => (
111- < Input id = "from" { ...field } placeholder = "sender@example.com" />
117+ < Input
118+ id = "from"
119+ { ...field }
120+ placeholder = "sender@example.com"
121+ />
112122 ) }
113123 />
114124 { errors . from && (
@@ -118,7 +128,9 @@ export function EmailDialog({
118128 ) }
119129 </ div >
120130 < div >
121- < Label htmlFor = "subject" > Subject < span className = "text-destructive font-medium" > *</ span > </ Label >
131+ < Label htmlFor = "subject" >
132+ Subject < span className = "text-destructive font-medium" > *</ span >
133+ </ Label >
122134 < Controller
123135 name = "subject"
124136 control = { control }
@@ -133,12 +145,19 @@ export function EmailDialog({
133145 ) }
134146 </ div >
135147 < div >
136- < Label htmlFor = "body" > Body < span className = "text-destructive font-medium" > *</ span > </ Label >
148+ < Label htmlFor = "body" >
149+ Body < span className = "text-destructive font-medium" > *</ span >
150+ </ Label >
137151 < Controller
138152 name = "body"
139153 control = { control }
140154 render = { ( { field } ) => (
141- < Textarea id = "body" { ...field } placeholder = "Email body content..." className = "min-h-[100px]" />
155+ < Textarea
156+ id = "body"
157+ { ...field }
158+ placeholder = "Email body content..."
159+ className = "min-h-[100px]"
160+ />
142161 ) }
143162 />
144163 { errors . body && (
@@ -164,4 +183,4 @@ export function EmailDialog({
164183 </ AlertDialogContent >
165184 </ AlertDialog >
166185 ) ;
167- }
186+ }
0 commit comments