-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add selects, change store from [] to {}
- Loading branch information
1 parent
fdcc871
commit d9bfdbf
Showing
5 changed files
with
139 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
/* | ||
* типы действий | ||
*/ | ||
|
||
export const ADD = 'ADD'; | ||
export const DONE = 'DONE'; | ||
export const SORT_RED = 'SORT_RED'; | ||
export const SORT_BLACK = 'SORT_BLACK'; | ||
export const SORT_ALL = 'SORT_ALL'; | ||
export const MARK_DONE = 'MARK_DONE'; | ||
/*export const SORT_REDX = 'SORT_REDX'; | ||
export const SORT_BLACKX = 'SORT_BLACKX'; | ||
export const SORT_ALLX = 'SORT_ALLX';*/ | ||
|
||
export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER'; | ||
|
||
/* | ||
* другие константы | ||
*/ | ||
|
||
export const VisibilityFilters = { | ||
SORT_RED : 'SORT_RED', | ||
SORT_BLACK : 'SORT_BLACK', | ||
SORT_ALL : 'SORT_ALL' | ||
} | ||
|
||
/* | ||
* генераторы действий | ||
*/ | ||
|
||
/*export function addTodo(text) { | ||
return { type: ADD_TODO, text } | ||
} | ||
export function toggleTodo(index) { | ||
return { type: TOGGLE_TODO, index } | ||
} | ||
export function setVisibilityFilter(filter) { | ||
return { type: SET_VISIBILITY_FILTER, filter } | ||
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import {VisibilityFilters} from './actions' | ||
|
||
export const getFilteredItems = (store) => { | ||
const currentFilter = store.currentFilter;// достаем текущий фильтр | ||
const items = store.items; | ||
// в зависимости от того какой фильтр, производим соответсвующие действия | ||
if (currentFilter === VisibilityFilters.SORT_RED) { | ||
return items.filter(item => items.isDone); | ||
} else if (currentFilter === VisibilityFilters.SORT_BLACK) { | ||
return items.filter(item => !items.isDone); | ||
} else if (currentFilter === VisibilityFilters.SORT_ALL) { | ||
return items.filter(item => item); | ||
} else { | ||
return items.filter(item => item); | ||
} | ||
}; |