+
>
);
diff --git a/apps/mail/components/create/email-composer.tsx b/apps/mail/components/create/email-composer.tsx
index eaacd5ef8..32b3b1830 100644
--- a/apps/mail/components/create/email-composer.tsx
+++ b/apps/mail/components/create/email-composer.tsx
@@ -93,6 +93,18 @@ interface EmailComposerProps {
isFullscreen?: boolean;
}
+type FormData = {
+ to: string[];
+ subject: string;
+ message: string;
+ attachments?: File[];
+ headers?: any;
+ cc?: string[];
+ bcc?: string[];
+ threadId?: string;
+ fromEmail?: string;
+};
+
const schema = z.object({
to: z.array(z.string().email()).min(1),
subject: z.string().min(1),
@@ -234,7 +246,7 @@ function EmailComposerBase({
trpc.ai.generateEmailSubject.mutationOptions(),
);
- const form = useForm
>({
+ const form = useForm({
resolver: zodResolver(schema),
defaultValues: {
to: initialTo,
@@ -542,9 +554,19 @@ function EmailComposerBase({
};
// Debounced onChange to prevent excessive re-renders
- const debouncedOnChange = useDebounce((updates: any) => {
- onChange?.(updates);
- }, 500);
+ const debouncedOnChange = useDebounce(
+ (updates: {
+ to?: string[];
+ cc?: string[];
+ bcc?: string[];
+ subject?: string;
+ body?: string;
+ attachments?: File[];
+ }) => {
+ onChange?.(updates);
+ },
+ 500,
+ );
// Add useEffect to notify parent of changes
useEffect(() => {
@@ -669,18 +691,16 @@ function EmailComposerBase({
return (
-
+
{/* To, Cc, Bcc */}
-
+
To:
@@ -811,7 +831,7 @@ function EmailComposerBase({
-
+
{aiGeneratedMessage !== null ? (
{/* Message Content */}
-
+
{
editor.commands.focus();
@@ -883,7 +903,7 @@ function EmailComposerBase({
{/* Bottom Actions */}
-
+