Skip to content
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

Merged
merged 4 commits into from
Dec 26, 2023
Merged

Feature/clear cart btn #184

merged 4 commits into from
Dec 26, 2023

Conversation

jsapro
Copy link
Collaborator

@jsapro jsapro commented Dec 26, 2023

#183
implement button clearing cart

@jsapro jsapro requested a review from Karmyshkov December 26, 2023 10:13
@jsapro jsapro self-assigned this Dec 26, 2023
};
successText: {
loadCartData: string;
updateCart: string;
deleteCart: string;
clearCart: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error и successText идет полное дублирование кода

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынес повторяющийся код в общий тип

setError((prev) => {
return { ...prev, clearCart: error.errors };
});
console.log('Error clearing cart:', error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR нужно чистить от console.log)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалил ненужные console.log

});
};

const clearCart = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно сократить до:

Suggested change
const clearCart = () => {
const clearCart = () => {
api
.usersShoppingCartDeleteAll()
.then(({ message }) => {
loadCartData();
setSuccessText((prev) => ({ ...prev, clearCart: message }));
})
.catch(({ errors }) => setError((prev) => ({ ...prev, clearCart: errors })));
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

body: JSON.stringify(data),
});
}
// usersShoppingCartRead(userId: string, id: number) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Закомментированный код лучше убирать если он не нужен. Если может пригодиться, нужно оставить TODO комментарий

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалил, т.к. скорее всего не пригодится

@jsapro jsapro merged commit cac1242 into develop Dec 26, 2023
4 checks passed
@jsapro jsapro deleted the feature/clear-cart-btn branch December 26, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants