-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecoil_state.ts
74 lines (65 loc) · 1.87 KB
/
recoil_state.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { ICard } from 'types'
import { COLUMN_NAMES, defaultTasks } from './constants'
import { atom, selector } from 'recoil'
export const columnListState = atom({
key: 'columnListState',
default: COLUMN_NAMES,
})
export const cardListState = atom<Array<ICard>>({
key: 'cardListState',
default: defaultTasks,
})
// export const cardsInColumn = selector({
// key: 'cardsInColumn',
// get: ({ get }) => {
// const cards = get(cardListState)
// cards.filter()
// return
// }
// })
// const todoListFilterState = atom({
// key: 'todoListFilterState',
// default: 'Show All',
// })
// const filteredTodoListState = selector({
// key: 'filteredTodoListState',
// get: ({ get }) => {
// const filter = get(todoListFilterState)
// const list = get(todoListState)
// switch (filter) {
// case 'Show Completed':
// return list.filter((item) => item.isComplete)
// case 'Show Uncompleted':
// return list.filter((item) => !item.isComplete)
// default:
// return list
// }
// },
// })
// const todoListStatsState = selector({
// key: 'todoListStatsState',
// get: ({ get }) => {
// const todoList = get(todoListState)
// const totalNum = todoList.length
// const totalCompletedNum = todoList.filter((item) => item.isComplete).length
// let allText = ''
// todoList
// .filter((item) => !item.isComplete)
// .map((item) => (allText = allText + ' ' + item.text))
// const totalUncompletedNum = totalNum - totalCompletedNum
// const percentCompleted = totalNum === 0 ? 0 : totalCompletedNum / totalNum
// return {
// totalNum,
// totalCompletedNum,
// totalUncompletedNum,
// percentCompleted,
// allText,
// }
// },
// })
// export {
// todoListState,
// todoListFilterState,
// filteredTodoListState,
// todoListStatsState,
// }