feat: hook up the request to the send mail form

This commit is contained in:
Ahmed Bouhuolia
2024-10-28 12:00:17 +02:00
parent 0930b0428d
commit 0111b0e6ff
7 changed files with 162 additions and 80 deletions

View File

@@ -0,0 +1,18 @@
import { useFormikContext } from 'formik';
import { chain } from 'lodash';
import { InvoiceSendMailFormValues } from './_types';
export const useInvoiceMailItems = () => {
const { values } = useFormikContext<InvoiceSendMailFormValues>();
const cc = values?.cc || [];
const bcc = values?.bcc || [];
return chain([...values?.to, ...cc, ...bcc])
.filter((email) => !!email?.trim())
.uniq()
.map((email) => ({
value: email,
text: email,
}))
.value();
};