feat(Flash): Get flash messages on load

This commit is contained in:
Berkeley Martinez
2018-01-12 11:09:09 -08:00
parent 387eafbf33
commit 2bb27e8dc6
7 changed files with 73 additions and 48 deletions

View File

@@ -0,0 +1,29 @@
import _ from 'lodash/fp';
export const alertTypes = _.keyBy(_.identity)([
'success',
'info',
'warning',
'danger'
]);
export const normalizeAlertType = alertType => alertTypes[alertType] || 'info';
export const getFlashAction = _.flow(
_.property('meta'),
_.property('flash')
);
export const isFlashAction = _.flow(
getFlashAction,
Boolean
);
export const expressToStack = _.flow(
_.toPairs,
_.flatMap(([ type, messages ]) => messages.map(({ msg }) => ({
message: msg,
alertType: normalizeAlertType(type)
})))
);