Skip to content

Commit

Permalink
results 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmodrr committed Dec 23, 2024
1 parent aabd6f9 commit 2a5584d
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import { Header } from './components/Header';
import { MyError } from './components/MyError';

function filterTodos(todos: Todo[], filterBy: string) {
const copy = [...todos];

switch (filterBy) {
case FILTER_BY.ALL:
return copy;
return todos;
case FILTER_BY.ACTIVE:
return copy.filter(e => !e.completed);
return todos.filter(e => !e.completed);
case FILTER_BY.COMPLETED:
return copy.filter(e => e.completed);
return todos.filter(e => e.completed);
}

return [];
Expand All @@ -43,9 +41,7 @@ export const App: React.FC = () => {
useEffect(() => {
setTimeout(() => {
getTodos()
.then(todosFromServer => {
setTodos(todosFromServer);
})
.then(setTodos)
.catch(() => setErrorMessage('Unable to load todos'));
}, 200);
}, []);
Expand Down Expand Up @@ -112,10 +108,6 @@ export const App: React.FC = () => {
if (isError) {
throw new Error('Unable to delete a todo');
}

// const isSuccess = results
// .filter(result => result.status === 'fulfilled')
// .map((_, index) => completedTodos[index].id);
} catch {
setErrorMessage('Unable to delete a todo');
} finally {
Expand Down

0 comments on commit 2a5584d

Please sign in to comment.