-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/clear cart btn #184
Conversation
src/contexts/cart-context.tsx
Outdated
}; | ||
successText: { | ||
loadCartData: string; | ||
updateCart: string; | ||
deleteCart: string; | ||
clearCart: string; |
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.
error и successText идет полное дублирование кода
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.
вынес повторяющийся код в общий тип
src/contexts/cart-context.tsx
Outdated
setError((prev) => { | ||
return { ...prev, clearCart: error.errors }; | ||
}); | ||
console.log('Error clearing cart:', error); |
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.
PR нужно чистить от console.log)
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.
удалил ненужные console.log
}); | ||
}; | ||
|
||
const clearCart = () => { |
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.
можно сократить до:
const clearCart = () => { | |
const clearCart = () => { | |
api | |
.usersShoppingCartDeleteAll() | |
.then(({ message }) => { | |
loadCartData(); | |
setSuccessText((prev) => ({ ...prev, clearCart: message })); | |
}) | |
.catch(({ errors }) => setError((prev) => ({ ...prev, clearCart: errors }))); | |
}; |
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.
👍
src/services/api.ts
Outdated
body: JSON.stringify(data), | ||
}); | ||
} | ||
// usersShoppingCartRead(userId: string, id: number) { |
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.
Закомментированный код лучше убирать если он не нужен. Если может пригодиться, нужно оставить TODO комментарий
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.
удалил, т.к. скорее всего не пригодится
#183
implement button clearing cart