<commit_before>/**
 * Created by michalfrystacky on 1/22/17.
 */
import expect from 'expect';
import deepFreeze from 'deep-freeze';
import {createStore, combineReducers} from 'redux';
import React from 'react';
import ReactDOM from 'react-dom';

const todo = (state, action) => {
    switch (action.type) {
        case 'ADD_TODO':
            return {
                id: action.id,
                text: action.text,
                completed: false
            };
        case 'TOGGLE_TODO':
            if (state.id !== action.id) {
                return state;
            }

            return {
                ...state,
                completed: !state.completed
            };
        default:
            return state;
    }
};

const todos = (state = [], action) => {
    switch (action.type) {
        case 'ADD_TODO':
            return [
                ...state,
                todo(undefined, action)
            ];
        case 'TOGGLE_TODO':
            return state.map(t => todo(t, action));
        default:
            return state;
    }
};

const visibilityFilter = (state = 'SHOW_ALL',
                          action) => {
    switch (action.type) {
        case 'SET_VISIBILITY_FILTER':
            return action.filter;
        default:
            return state;
    }
};
/*
 const combineReducers = (reducers) => {
 return (state = {}, action) => {
 return Object.keys(reducers).reduce(
 (nextState, key) => {
 nextState[key] = reducers[key](
 state[key],
 action
 );
 return nextState
 },
 {}
 );
 };
 };
 */
/*
const todoApp = (state = {}, action) => {
    return {
 todos: todos(
            state.todo,
            action
        ),
        visibilityFilter: visibilityFilter(
            state.visibilityFilter,
            action
        )
    };
};
 */
const todoApp = combineReducers({
    todos,
    visibilityFilter
});

const store = createStore(todoApp);

const getVisibleTodos = (
    todos,
    filter
) => {
  switch(filter) {
      case 'SHOW_ALL':
          return todos;
      case 'SHOW_COMPLETED':
          return todos.filter(
              t => t.completed
          );
      case 'SHOW_ACTIVE':
          return todos.filter(
              t => !t.completed
          );
      default:
          return todos;
  }
};

const FilterLink = ({
    filter,
    currentFilter,
    children
}) => {
    if (filter === currentFilter) {
        return <span>{children}</span>;
    }

    return (
        <a href="#"
           onClick={e => {
               e.preventDefault();
               store.dispatch({
                   type: 'SET_VISIBILITY_FILTER',
                   filter
               });
           }}
        >
            {children}
        </a>

    );
};

const FilterLinks = ({
    filters,
    currentFilter
}) => {
    return (
        <p>
            {filters.map(f => {
                return (
                    <FilterLink
                        filter={f[0]}
                        currentFilter={currentFilter}
                    >
                        {f[1]}

                    </FilterLink>
                );
            })}
        </p>
    );
};

let nextToDoId = 0;
class TodoApp extends React.Component {
    render() {
        const {<commit_msg>Feat: Added commas within filterlinks<commit_after>/**
 * Created by michalfrystacky on 1/22/17.
 */
import expect from 'expect';
import deepFreeze from 'deep-freeze';
import {createStore, combineReducers} from 'redux';
import React from 'react';
import ReactDOM from 'react-dom';

const todo = (state, action) => {
    switch (action.type) {
        case 'ADD_TODO':
            return {
                id: action.id,
                text: action.text,
                completed: false
            };
        case 'TOGGLE_TODO':
            if (state.id !== action.id) {
                return state;
            }

            return {
                ...state,
                completed: !state.completed
            };
        default:
            return state;
    }
};

const todos = (state = [], action) => {
    switch (action.type) {
        case 'ADD_TODO':
            return [
                ...state,
                todo(undefined, action)
            ];
        case 'TOGGLE_TODO':
            return state.map(t => todo(t, action));
        default:
            return state;
    }
};

const visibilityFilter = (state = 'SHOW_ALL',
                          action) => {
    switch (action.type) {
        case 'SET_VISIBILITY_FILTER':
            return action.filter;
        default:
            return state;
    }
};
/*
 const combineReducers = (reducers) => {
 return (state = {}, action) => {
 return Object.keys(reducers).reduce(
 (nextState, key) => {
 nextState[key] = reducers[key](
 state[key],
 action
 );
 return nextState
 },
 {}
 );
 };
 };
 */
/*
const todoApp = (state = {}, action) => {
    return {
 todos: todos(
            state.todo,
            action
        ),
        visibilityFilter: visibilityFilter(
            state.visibilityFilter,
            action
        )
    };
};
 */
const todoApp = combineReducers({
    todos,
    visibilityFilter
});

const store = createStore(todoApp);

const getVisibleTodos = (
    todos,
    filter
) => {
  switch(filter) {
      case 'SHOW_ALL':
          return todos;
      case 'SHOW_COMPLETED':
          return todos.filter(
              t => t.completed
          );
      case 'SHOW_ACTIVE':
          return todos.filter(
              t => !t.completed
          );
      default:
          return todos;
  }
};

const FilterLink = ({
    filter,
    currentFilter,
    children
}) => {
    if (filter === currentFilter) {
        return <span>{children}, </span>;
    }

    return (
        <a href="#"
           onClick={e => {
               e.preventDefault();
               store.dispatch({
                   type: 'SET_VISIBILITY_FILTER',
                   filter
               });
           }}
        >
            {children},
        </a>

    );
};

const FilterLinks = ({
    filters,
    currentFilter
}) => {
    return (
        <p>
            {filters.map(f => {
                return (
                    <FilterLink
                        filter={f[0]}
                        currentFilter={currentFilter}
                    >
                        {f[1]}

                    </FilterLink>
                );
            })}
        </p>
    );
};

let nextToDoId = 0;
class TodoApp extends React.Component {
    render() {
        const {
{'fraction_non_alphanumeric': 0.1239060340856748, 'fraction_numerical': 0.002456625211116229, 'mean_word_length': 1.3214540270848183, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '672618', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1799, 'n_words': 397}