diff --git a/apps/web/app/(app)/compose/ComposeEmailForm.tsx b/apps/web/app/(app)/compose/ComposeEmailForm.tsx index 1f18e6344f..d040bee436 100644 --- a/apps/web/app/(app)/compose/ComposeEmailForm.tsx +++ b/apps/web/app/(app)/compose/ComposeEmailForm.tsx @@ -116,6 +116,7 @@ export const ComposeEmailForm = ({ ); const [searchQuery, setSearchQuery] = React.useState(""); + const [searchQueryCc, setSearchQueryCc] = React.useState(""); const { data } = useSWR( env.NEXT_PUBLIC_CONTACTS_ENABLED ? `/api/google/contacts?query=${searchQuery}` @@ -126,23 +127,28 @@ export const ComposeEmailForm = ({ ); // TODO not in love with how this was implemented - const selectedEmailAddressses = watch("to", "").split(",").filter(Boolean); + const selectedEmailAddresses = watch("to", "").split(",").filter(Boolean); + const selectedCcAddresses = (watch("cc") || "").split(",").filter(Boolean); - const onRemoveSelectedEmail = (emailAddress: string) => { - const filteredEmailAddresses = selectedEmailAddressses.filter( - (email) => email !== emailAddress, - ); - setValue("to", filteredEmailAddresses.join(",")); + const onRemoveSelectedEmail = (emailAddress: string, field: "to" | "cc") => { + const filteredEmailAddresses = ( + field === "to" ? selectedEmailAddresses : selectedCcAddresses + ).filter((email) => email !== emailAddress); + setValue(field, filteredEmailAddresses.join(",")); }; - const handleComboboxOnChange = (values: string[]) => { - // this assumes last value given by combobox is user typed value + // this assumes last value given by combobox is user typed value + const handleComboboxOnChange = (values: string[], field: "to" | "cc") => { const lastValue = values[values.length - 1]; const { success } = z.string().email().safeParse(lastValue); if (success) { - setValue("to", values.join(",")); - setSearchQuery(""); + setValue(field, values.join(",")); + if (field === "to") { + setSearchQuery(""); + } else { + setSearchQueryCc(""); + } } }; @@ -188,129 +194,266 @@ export const ComposeEmailForm = ({ ) : ( <> {env.NEXT_PUBLIC_CONTACTS_ENABLED ? ( -
-
-
+ ) : ( - + <> + + + )} setShowReply(true), []); + const onReplyAll = useCallback(() => setShowReplyAll(true), []); const [showForward, setShowForward] = useState(false); const onForward = useCallback(() => setShowForward(true), []); const onCloseCompose = useCallback(() => { setShowReply(false); + setShowReplyAll(false); setShowForward(false); }, []); @@ -80,6 +84,7 @@ export function EmailMessage({ toggleDetails={toggleDetails} showReplyButton={showReplyButton} onReply={onReply} + onReplyAll={onReplyAll} onForward={onForward} /> @@ -95,16 +100,17 @@ export function EmailMessage({ {message.attachments && } - {(showReply || showForward) && ( + {(showReply || showReplyAll || showForward) && ( )} @@ -121,6 +127,7 @@ function TopBar({ showReplyButton, onReply, onForward, + onReplyAll, }: { message: ParsedMessage; expanded: boolean; @@ -129,6 +136,7 @@ function TopBar({ showReplyButton: boolean; onReply: () => void; onForward: () => void; + onReplyAll: () => void; }) { return (
@@ -172,6 +180,12 @@ function TopBar({ Reply + + +