Skip to content

Commit

Permalink
Fixed due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Nov 6, 2020
1 parent 8ba2a3f commit 9d5595d
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,17 @@ export const AlertForm = ({
setDefaultActionGroupId(index.get(alert.alertTypeId)!.defaultActionGroupId);
}
setAlertTypesIndex(index);
setAvailableAlertTypes(getAvailableAlertTypes(alertTypesResult));
setSolutions(
alertTypesResult.reduce((result: Array<{ id: string; title: string }>, alertTypeItem) => {
if (!result.find((solution) => solution.id === alertTypeItem.producer)) {
const availableAlertTypesResult = getAvailableAlertTypes(alertTypesResult);
setAvailableAlertTypes(availableAlertTypesResult);

const solutionsResult = alertTypesResult.reduce(
(result: Array<{ id: string; title: string }>, alertTypeItem) => {
if (
availableAlertTypesResult.find(
(availableItem) => availableItem.alertTypeModel.id === alertTypeItem.id
) &&
!result.find((solution) => solution.id === alertTypeItem.producer)
) {
result.push({
id: alertTypeItem.producer,
title:
Expand All @@ -186,7 +193,11 @@ export const AlertForm = ({
});
}
return result;
}, [])
},
[]
);
setSolutions(
solutionsResult.sort((a, b) => a.title.toString().localeCompare(b.title.toString()))
);
} catch (e) {
toastNotifications.addDanger({
Expand Down Expand Up @@ -290,7 +301,7 @@ export const AlertForm = ({
name:
typeof alertTypeValue.alertTypeModel.name === 'string'
? alertTypeValue.alertTypeModel.name
: alertTypeValue.alertTypeModel.id,
: alertTypeValue.alertTypeModel.name.props.defaultMessage,
id: alertTypeValue.alertTypeModel.id,
alertTypeItem: alertTypeValue.alertTypeModel,
});
Expand Down

0 comments on commit 9d5595d

Please sign in to comment.