Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/actions/email-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const normalizeEntity = (entity) => {
return normalizedEntity;
};

export const queryTemplates = debounce(async (input, callback) => {
export const queryTemplates = debounce(async (input, callback, onError) => {
const accessToken = await getAccessTokenSafely();

const endpoint = URI(`${window.EMAIL_API_BASE_URL}/api/v1/mail-templates`);
Expand All @@ -274,7 +274,10 @@ export const queryTemplates = debounce(async (input, callback) => {

callback(options);
})
.catch(fetchErrorHandler);
.catch((err) => {
fetchErrorHandler(err);
if (onError) onError(err);
});
}, DEBOUNCE_WAIT);

/** ********************************************************************************************************* */
Expand Down
56 changes: 56 additions & 0 deletions src/components/mui/chip-multi-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from "react";
import {
Box,
Chip,
FormControl,
InputLabel,
MenuItem,
OutlinedInput,
Select
} from "@mui/material";
import CancelIcon from "@mui/icons-material/Cancel";

const ChipMultiSelect = ({ id, label, value, onChange, options, sx }) => {
const handleDelete = (val) =>
onChange({ target: { value: value.filter((v) => v !== val) } });

return (
<FormControl fullWidth size="small" sx={sx}>
<InputLabel id={`${id}-label`}>{label}</InputLabel>
<Select
labelId={`${id}-label`}
id={id}
multiple
value={value}
onChange={onChange}
input={<OutlinedInput label={label} />}
renderValue={(selected) => (
<Box sx={{ display: "flex", flexWrap: "wrap", gap: 0.5 }}>
{selected.map((val) => {
const option = options.find((o) => o.value === val);
return option ? (
<Chip
key={val}
label={option.label}
size="small"
onDelete={() => handleDelete(val)}
deleteIcon={
<CancelIcon onMouseDown={(ev) => ev.stopPropagation()} />
}
/>
) : null;
})}
</Box>
)}
>
{options.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</Select>
</FormControl>
);
};

export default ChipMultiSelect;
5 changes: 4 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3265,6 +3265,7 @@
}
},
"emails": {
"emails": "Emails",
"email_templates": "Email Templates",
"sent": "Sent",
"templates": "Templates",
Expand Down Expand Up @@ -3319,6 +3320,9 @@
"email_logs": "Email Logs",
"email_list": "Email List",
"apply_filters": "Apply Filters",
"enabled_filters": "Enabled Filters",
"all": "All",
"not_sent": "Not Sent",
"email_templates": "Email Templates",
"subject": "Subject",
"from_email": "From Email",
Expand All @@ -3328,7 +3332,6 @@
"payload": "Payload",
"select_fields": "Show Columns",
"placeholders": {
"select_fields": "Select data to display",
"template": "Filter by Template",
"sent_date_from": "Filter Sent Date from",
"sent_date_to": "Filter Sent Date to"
Expand Down
Loading
Loading