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.
This commit is contained in:
parent
ac1cdfb115
commit
d977b3701b
@ -339,6 +339,8 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => {
|
|||||||
const handleTargetSampleModalOpen = () => {
|
const handleTargetSampleModalOpen = () => {
|
||||||
setTargetSampleModalOpen(!TargetSampleModalOpen);
|
setTargetSampleModalOpen(!TargetSampleModalOpen);
|
||||||
};
|
};
|
||||||
|
const filteredTargets = setupData.targets.filter(t => t.isActive);
|
||||||
|
const filteredTemplates = setupData.templates.filter(t => t.isActive);
|
||||||
return (
|
return (
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}> {/* Wrap with LocalizationProvider */}
|
<LocalizationProvider dateAdapter={AdapterDayjs}> {/* Wrap with LocalizationProvider */}
|
||||||
<Dialog open={open} onClose={(_, reason) => { onClose(reason); }} maxWidth="sm" fullWidth disableEscapeKeyDown >
|
<Dialog open={open} onClose={(_, reason) => { onClose(reason); }} maxWidth="sm" fullWidth disableEscapeKeyDown >
|
||||||
@ -368,9 +370,9 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
{...field}
|
{...field}
|
||||||
options={setupData.templates}
|
options={filteredTemplates}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
value={setupData.templates.find(t => t.id === field.value) || null}
|
value={filteredTemplates.find(t => t.id === field.value) || null}
|
||||||
onChange={(_, newValue) => {
|
onChange={(_, newValue) => {
|
||||||
field.onChange(newValue ? newValue.id : null);
|
field.onChange(newValue ? newValue.id : null);
|
||||||
trigger("templateId");
|
trigger("templateId");
|
||||||
@ -409,9 +411,9 @@ const MailingEdit = ({ open, mailing, onClose, onSave }: MailingEditProps) => {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
{...field}
|
{...field}
|
||||||
options={setupData.targets}
|
options={filteredTargets}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
value={setupData.targets.find(t => t.id === field.value) || null}
|
value={filteredTargets.find(t => t.id === field.value) || null}
|
||||||
onChange={(_, newValue) => {
|
onChange={(_, newValue) => {
|
||||||
field.onChange(newValue ? newValue.id : null);
|
field.onChange(newValue ? newValue.id : null);
|
||||||
trigger("targetId");
|
trigger("targetId");
|
||||||
|
|||||||
@ -141,6 +141,7 @@ const TemplateEdit = ({ open, template, onClose, onSave }: TemplateEditProps) =>
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const filteredEmailDomains = setupData.emailDomains.filter((domain) => domain.isActive);
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
@ -221,9 +222,9 @@ const TemplateEdit = ({ open, template, onClose, onSave }: TemplateEditProps) =>
|
|||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
options={setupData.emailDomains}
|
options={filteredEmailDomains}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => 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)}
|
onChange={(_, newValue) => field.onChange(newValue ? newValue.id : null)}
|
||||||
renderInput={(params) => (
|
renderInput={(params) => (
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user