Skip to content

Commit cae9274

Browse files
committed
add in-progress button to UnderBar
1 parent d022b72 commit cae9274

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/App/TodoList/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ReactElement } from 'react'
1+
import { ReactElement, useEffect } from 'react'
22
import React from 'react'
33
import { useLocation } from 'react-router-dom'
44
import { useRecoilState } from 'recoil'
@@ -13,11 +13,20 @@ const TodoList: React.FC = () => {
1313
const { pathname } = useLocation()
1414
const [appState, setAppState] = useRecoilState<AppState>(recoilState)
1515

16-
function toggleAllCheckbox(e: React.ChangeEvent<HTMLInputElement>): void { /* eslint-disable-line prettier/prettier */
16+
function toggleAllCheckbox(e: React.ChangeEvent<HTMLInputElement>): void {
17+
/* eslint-disable-line prettier/prettier */
1718
// reverse all todo.completed: boolean flag
18-
setAppState({ todoList: appState.todoList.map((t: Todo): Todo => ({ ...t, completed: e.target.checked })) }) /* eslint-disable-line prettier/prettier */
19+
setAppState({
20+
todoList: appState.todoList.map(
21+
(t: Todo): Todo => ({ ...t, completed: e.target.checked })
22+
),
23+
}) /* eslint-disable-line prettier/prettier */
1924
}
2025

26+
useEffect(() => {
27+
console.log('appState', appState)
28+
}, [appState])
29+
2130
return (
2231
<Layout>
2332
<section className="main">
@@ -36,7 +45,7 @@ const TodoList: React.FC = () => {
3645
switch (pathname) {
3746
case '/':
3847
return true
39-
case '/active':
48+
case '/backlog':
4049
return t.completed === false
4150
case '/completed':
4251
return t.completed === true

src/App/UnderBar/FilterLink/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ const FilterLink: React.FC = () => {
1717
<li>
1818
<Link
1919
data-cy="active-filter"
20-
className={pathname === '/active' ? 'selected' : ''}
21-
to="/active"
20+
className={pathname === '/backlog' ? 'selected' : ''}
21+
to="/backlog"
2222
>
23-
Active
23+
Backlog
24+
</Link>
25+
</li>
26+
<li>
27+
<Link
28+
data-cy="active-filter"
29+
className={pathname === '/in-progress' ? 'selected' : ''}
30+
to="/in-progress"
31+
>
32+
In progress
2433
</Link>
2534
</li>
2635
<li>

src/App/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ const App: React.FC = () => (
1212
<RecoilRoot>
1313
<Routes>
1414
<Route path="/" element={<TodoMVC />} />
15-
<Route path="/active" element={<TodoMVC />} />
15+
<Route path="/backlog" element={<TodoMVC />} />
1616
<Route path="/completed" element={<TodoMVC />} />
17+
<Route path="/in-progress" element={<TodoMVC />} />
1718
<Route path="*" element={<NotFound />} />
1819
</Routes>
1920
</RecoilRoot>

src/dataStructure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Todo {
77
id: string
88
bodyText: string
99
completed: boolean
10+
inProgress: boolean
1011
}
1112

1213
export type TodoListType = Todo[]

0 commit comments

Comments
 (0)