MetaPhase-Consulting/State-TalentMAP

View on GitHub
src/actions/showFeedback.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { focusById } from '../utilities';
import { FEEDBACK_INPUT_ID, FEEDBACK_OPEN_ICON_ID } from '../Constants/HtmlAttributes';

export function shouldShowFeedback(shouldShow) {
  return {
    type: 'SHOULD_SHOW_FEEDBACK',
    shouldShow,
  };
}

export function toggleFeedback(show = true) {
  return (dispatch) => {
    dispatch(shouldShowFeedback(show));
    // focus search on glossary open
    if (show) { focusById(FEEDBACK_INPUT_ID); }
    if (!show) { focusById(FEEDBACK_OPEN_ICON_ID); }
  };
}