* fix(layout): Fix Settings layout in firefox * chore(availableForHire): Remove available for hire setting * feat(helpers): Use helper components for Settings layout * fix(map): Fix undefined lang requested * feat(settings): Expand Settings page functionality * chore(pledge): Remove pledge from Settings * fix(about): Adjust AboutSettings layout * fix(portfolio): Improve PortfolioSettings layout * fix(email): Improve EmailSettings layout * fix(settings): Align save buttons with form fields * fix(AHP): Format AHP * fix(DangerZone): Adjust DangerZone layout * fix(projectSettings): Change Button Copy * fix(CertSettings): Fix certificate claim logic * chore(lint): Lint
		
			
				
	
	
		
			48 lines
		
	
	
		
			925 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			925 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import {
 | 
						|
  createAction,
 | 
						|
  createTypes,
 | 
						|
  handleActions
 | 
						|
} from 'berkeleys-redux-utils';
 | 
						|
 | 
						|
import ns from '../ns.json';
 | 
						|
 | 
						|
export const types = createTypes([
 | 
						|
  'makeToast',
 | 
						|
  'removeToast'
 | 
						|
], ns);
 | 
						|
 | 
						|
let key = 0;
 | 
						|
export const makeToast = createAction(
 | 
						|
  types.makeToast,
 | 
						|
  ({ timeout, ...rest }) => ({
 | 
						|
    ...rest,
 | 
						|
    // assign current value of key to new toast
 | 
						|
    // and then increment key value
 | 
						|
    key: key++,
 | 
						|
    dismissAfter: timeout || 6000,
 | 
						|
    position: rest.position === 'left' ? 'left' : 'right'
 | 
						|
  })
 | 
						|
);
 | 
						|
 | 
						|
export const removeToast = createAction(
 | 
						|
  types.removeToast,
 | 
						|
  ({ key }) => key
 | 
						|
);
 | 
						|
 | 
						|
 | 
						|
const initialState = [];
 | 
						|
 | 
						|
export default handleActions(
 | 
						|
  () => ({
 | 
						|
    [types.makeToast]: (state, { payload: toast }) => [
 | 
						|
      ...state,
 | 
						|
      toast
 | 
						|
    ].filter(toast => !!toast.message),
 | 
						|
    [types.removeToast]: (state, { payload: key }) => state.filter(
 | 
						|
      toast => toast.key !== key
 | 
						|
    )
 | 
						|
  }),
 | 
						|
  initialState,
 | 
						|
  ns
 | 
						|
);
 |