Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszSlezak committed Oct 11, 2023
1 parent 1030af5 commit bca1ddc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 53 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Todo } from './types/Todo';
const USER_ID = 11569;

export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[] >([]);
const [todos, setTodos] = useState<Todo[] | [] >([]);
const [isLoading, setIsLoading] = useState<number[] | []>([]);
const [statusFilter, setStatusFilter] = useState('all');
const [tempTodo, setTempTodo] = useState<Todo | null>(null);
Expand All @@ -34,7 +34,7 @@ export const App: React.FC = () => {
useEffect(() => {
getTodos(USER_ID)
.then((data) => {
const todosData = data as Todo[];
const todosData = data;

setTodos(todosData);
setTodos(data);
Expand Down Expand Up @@ -124,7 +124,7 @@ export const App: React.FC = () => {
}).catch(() => {
setError('Unable to delete a todo');
}).finally(() => {
setIsLoading(todos.filter(todo => todo.id !== todoId) as number[] | []);
setIsLoading(isLoading.filter(id => id !== todoId));
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/api/todos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getTodo = (todoId: number) => {
return client.get<Todo[]>(`/todos/${todoId}`);
};

export const addTodo = (todo: {}) => {
export const addTodo = (todo: Partial<Todo>) => {
return client.post('/todos', todo);
};

Expand Down
49 changes: 0 additions & 49 deletions src/components/ToDoContext.tsx

This file was deleted.

0 comments on commit bca1ddc

Please sign in to comment.