{"size": 1483, "ext": "js", "max_stars_repo_path": "app/containers/Sidebar.js", "max_stars_repo_name": "gitter-badger/mdyna-app", "max_stars_repo_stars_event_min_datetime": "2019-04-22T21:04:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T04:29:55.000Z", "max_issues_repo_path": "app/containers/Sidebar.js", "max_issues_repo_name": "gitter-badger/mdyna-app", "max_issues_repo_issues_event_min_datetime": "2019-03-10T02:08:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:38:08.000Z", "max_forks_repo_path": "app/containers/Sidebar.js", "max_forks_repo_name": "gitter-badger/mdyna-app", "max_forks_repo_forks_event_min_datetime": "2020-01-28T04:53:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T21:21:18.000Z"}
{"max_stars_count": 73, "max_issues_count": 20, "max_forks_count": 12, "avg_line_length": 22.8153846154, "max_line_length": 55, "alphanum_fraction": 0.6587997303}
import ACTIONS from 'Store/actions/';
import React from 'react';
import Sidebar from 'Components/Sidebar';
import { connect } from 'react-redux';
import { toast } from 'react-toastify';

const {
  SETTINGS, FILTERS, BOARDS, CARD,
} = ACTIONS;

const { addCard, clearArchive } = CARD;

const { toggleSidebar, toggleSettings } = SETTINGS;

const { toggleBoardsDialog } = BOARDS;

const {
  searchCards,
  focusCard,
  toggleArchivedFilter,
} = FILTERS;

function mapDispatchToProps(dispatch) {
  return {
    toggleSettings: () => {
      dispatch(toggleSettings());
    },
    toggleBoardsDialog: () => {
      dispatch(toggleBoardsDialog());
    },
    clearArchive: () => {
      dispatch(clearArchive());
      toast.info('Cleared archived cards');
    },
    toggleSidebar: () => {
      dispatch(toggleSidebar());
    },
    onChange: (val) => {
      dispatch(searchCards(val));
    },
    toggleArchivedFilter: (val) => {
      dispatch(toggleArchivedFilter(val));
    },
    addCard: (activeBoard, card) => {
      dispatch(addCard(activeBoard, card));
      dispatch(searchCards(''));
      dispatch(focusCard());
    },
  };
}

function mapStateToProps(state) {
  return {
    activeBoard: state.filters.activeBoard,
    archivedFilterOn: state.filters.archivedFilterOn,
    githubAuthOn: state.settings.githubAuthOn || false,
    sidebarExpanded: state.style.sidebarExpanded,
  };
}

export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(React.memo(Sidebar));
