-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #832
base: master
Are you sure you want to change the base?
Solution #832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, few changes needed ✅
src/App.tsx
Outdated
client | ||
.patch(`/todos/${todoId}`, { completed: !todoToToggle.completed }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to add it to api methods
src/App.tsx
Outdated
const allTodosAreCompleted = todos.length === completedTodos.length; | ||
|
||
const promiseArray = (allTodosAreCompleted ? completedTodos : activeTodos) | ||
.map((todo: { id: number; completed: boolean; }) => client.patch(`/todos/${todo.id}`, { completed: !todo.completed })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also be a api method
src/App.tsx
Outdated
return client | ||
.patch<Todo>(`/todos/${todoId}`, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api method
src/api/todos.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all API methods should go here
}) => { | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) => { | |
return ( | |
}) => ( |
client | ||
.patch(`/todos/${todo.id}`, { title: newTodoTitle }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api method
export const TodoStatus: React.FC<Props> = ({ status, onStatusChange }) => { | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const TodoStatus: React.FC<Props> = ({ status, onStatusChange }) => { | |
return ( | |
export const TodoStatus: React.FC<Props> = ({ status, onStatusChange }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
DEMO LINK