feat(Flash): Normalize flash types with object
help prevent typo errors
This commit is contained in:
@@ -4,7 +4,7 @@ import { CloseButton } from 'react-bootstrap';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import ns from './ns.json';
|
||||
import { alertTypes } from './redux/utils.js';
|
||||
import { alertTypes } from '../../utils/flash.js';
|
||||
import {
|
||||
latestMessageSelector,
|
||||
clickOnClose
|
||||
|
@@ -1,13 +1,5 @@
|
||||
import _ from 'lodash/fp';
|
||||
|
||||
export const alertTypes = _.keyBy(_.identity)([
|
||||
'success',
|
||||
'info',
|
||||
'warning',
|
||||
'danger'
|
||||
]);
|
||||
|
||||
export const normalizeAlertType = alertType => alertTypes[alertType] || 'info';
|
||||
import { alertTypes, normalizeAlertType } from '../../../utils/flash.js';
|
||||
|
||||
// interface ExpressFlash {
|
||||
// [alertType]: [String...]
|
||||
@@ -16,7 +8,6 @@ export const normalizeAlertType = alertType => alertTypes[alertType] || 'info';
|
||||
// type: AlertType,
|
||||
// message: String
|
||||
// }
|
||||
|
||||
export const expressToStack = _.flow(
|
||||
_.toPairs,
|
||||
_.flatMap(([ type, messages ]) => messages.map(msg => ({
|
||||
|
10
common/utils/flash.js
Normal file
10
common/utils/flash.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export const alertTypes = _.keyBy([
|
||||
'success',
|
||||
'info',
|
||||
'warning',
|
||||
'danger'
|
||||
], _.identity);
|
||||
|
||||
export const normalizeAlertType = alertType => alertTypes[alertType] || 'info';
|
Reference in New Issue
Block a user