2018-01-12 11:09:09 -08:00
|
|
|
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,
|
2018-01-20 08:29:34 -08:00
|
|
|
_.flatMap(([ type, messages ]) => messages.map(msg => ({
|
2018-01-12 11:09:09 -08:00
|
|
|
message: msg,
|
|
|
|
alertType: normalizeAlertType(type)
|
|
|
|
})))
|
|
|
|
);
|
|
|
|
|