From d977b3701b85f9792e7f1d5c9f949b0041c4cb57 Mon Sep 17 00:00:00 2001 From: David Headrick Date: Wed, 9 Apr 2025 10:20:51 -0500 Subject: [PATCH] Filter active items in MailingEdit and TemplateEdit Updated Autocomplete options to use filtered lists of active targets, templates, and email domains. This change ensures that only active items are displayed in the dropdowns for selection. --- .../src/components/modals/MailingEdit.tsx | 10 ++++++---- .../src/components/modals/TemplateEdit.tsx | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Surge365.MassEmailReact.Web/src/components/modals/MailingEdit.tsx b/Surge365.MassEmailReact.Web/src/components/modals/MailingEdit.tsx index 3e5517a..824f334 100644 --- a/Surge365.MassEmailReact.Web/src/components/modals/MailingEdit.tsx +++ b/Surge365.MassEmailReact.Web/src/components/modals/MailingEdit.tsx @@ -339,6 +339,8 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => { const handleTargetSampleModalOpen = () => { setTargetSampleModalOpen(!TargetSampleModalOpen); }; + const filteredTargets = setupData.targets.filter(t => t.isActive); + const filteredTemplates = setupData.templates.filter(t => t.isActive); return ( {/* Wrap with LocalizationProvider */} { onClose(reason); }} maxWidth="sm" fullWidth disableEscapeKeyDown > @@ -368,9 +370,9 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => { render={({ field }) => ( option.name} - value={setupData.templates.find(t => t.id === field.value) || null} + value={filteredTemplates.find(t => t.id === field.value) || null} onChange={(_, newValue) => { field.onChange(newValue ? newValue.id : null); trigger("templateId"); @@ -409,9 +411,9 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => { render={({ field }) => ( option.name} - value={setupData.targets.find(t => t.id === field.value) || null} + value={filteredTargets.find(t => t.id === field.value) || null} onChange={(_, newValue) => { field.onChange(newValue ? newValue.id : null); trigger("targetId"); diff --git a/Surge365.MassEmailReact.Web/src/components/modals/TemplateEdit.tsx b/Surge365.MassEmailReact.Web/src/components/modals/TemplateEdit.tsx index ad2bf57..30ce2f2 100644 --- a/Surge365.MassEmailReact.Web/src/components/modals/TemplateEdit.tsx +++ b/Surge365.MassEmailReact.Web/src/components/modals/TemplateEdit.tsx @@ -141,6 +141,7 @@ const TemplateEdit = ({ open, template, onClose, onSave }: TemplateEditProps) => ); + const filteredEmailDomains = setupData.emailDomains.filter((domain) => domain.isActive); return ( control={control} render={({ field }) => ( option.name} - value={setupData.emailDomains.find((d) => d.id === field.value) || null} + value={filteredEmailDomains.find((d) => d.id === field.value) || null} onChange={(_, newValue) => field.onChange(newValue ? newValue.id : null)} renderInput={(params) => (