further cleanup

This commit is contained in:
Ken
2019-01-31 11:24:18 -08:00
parent fceb24f985
commit f2ca4ea884
3 changed files with 9 additions and 12 deletions

View File

@@ -8,15 +8,15 @@ function action<T extends string, P>(type: T, payload?: P) {
return { type, ...payload };
}
export const add = (label: string) => action('add', { label });
export const remove = (id: string) => ({ type: 'remove' as 'remove', id });
export const edit = (id: string, label: string) => ({ type: 'edit' as 'edit', id, label });
export const complete = (id: string) => ({ type: 'complete' as 'complete', id });
export const completeAll = () => ({ type: 'completeAll' as 'completeAll' });
export const clear = () => ({ type: 'clear' as 'clear' });
export const filter = (filterTypes: string) => ({ type: 'filter' as 'filter', filter: filterTypes });
export const actions = { add, remove, edit, complete, completeAll, clear, filter };
export const actions = {
add: (label: string) => action('add', { label }),
remove: (id: string) => action('remove', { id }),
edit: (id: string, label: string) => action('edit', { id, label }),
complete: (id: string) => action('complete', { id }),
completeAll: () => action('completeAll'),
clear: () => action('clear'),
filter: (filterTypes: string) => action('filter', { filter: filterTypes })
};
export type ActionTypes = ReturnType<typeof actions[keyof typeof actions]>['type'];
export type TodoAction = ReturnType<typeof actions[ActionTypes]>;

View File

@@ -1,7 +1,6 @@
import React from 'react';
import { Text, Stack } from '@uifabric/experiments';
import { Pivot, PivotItem, TextField } from 'office-ui-fabric-react';
import { add } from '../actions';
import { FilterTypes } from '../store';
export interface TodoHeaderProps {

View File

@@ -1,8 +1,6 @@
import { createReducer } from './createReducer';
import { Store, FilterTypes } from '../store';
import { combineReducers } from 'redux';
import produce from 'immer';
import { edit } from '../actions';
let counter = 0;