-
Notifications
You must be signed in to change notification settings - Fork 1
Sprint 4: Basket Page, Catalog Page Enhancements, and About Us Page Implementation #50
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
Conversation
Bumps the npm_and_yarn group with 1 update in the / directory: [brace-expansion](https://github.com/juliangruber/brace-expansion). Updates `brace-expansion` from 1.1.11 to 1.1.12 - [Release notes](https://github.com/juliangruber/brace-expansion/releases) - [Commits](juliangruber/brace-expansion@1.1.11...v1.1.12) --- updated-dependencies: - dependency-name: brace-expansion dependency-version: 1.1.12 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <[email protected]>
…yarn-6ea9762674 build(deps): Bump brace-expansion from 1.1.11 to 1.1.12 in the npm_and_yarn group across 1 directory
feat: ECOM-80 add pagination to catalog page
ECOM-79 Integrate Catalog Page with Commercetools API; ECOM-95 Routing to Basket Page
feat: ECOM-88 add message when cart is empty
…/fe-ecommerce into feature/ECOM-91
feat: ECOM-90 add clear shopping cart button
feat: ECOM-85 add product item quantity control
ECOM-84 Fetch and Display Cart Items
…/fe-ecommerce into feature/ECOM-91
ECOM-89 Apply Promo Code and Display Updated Prices
Added About Us page, add/remove item on product page
ECOM-96 add Quantity Indicator to header
…/fe-ecommerce into feature/ECOM-91
Change color theme and fix discount layout
refactor: ECOM-89 add some styles to discount card
fix: ECOM-83 cart item info flex box, Discounts header
Fix Breadcrumbs test
Code style PR updates
test: ECOM-83 add cart item view, empty cart, quantity control tests
test: ECOM-83 fix empty cart test
Crosscheck fixes
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.
Great job overall! The structure is clean, the typing is thoughtful, and it's clear you're paying attention to error handling and async flow. Just a few tweaks and it'll be even more maintainable. Keep up the good work)
const handleClick = async (event: MouseEvent<HTMLButtonElement>): Promise<void> => { | ||
event.stopPropagation() | ||
setIsLoading(true) | ||
setError(undefined) | ||
try { | ||
if (isInCart) { | ||
await dispatch(removeProduct({ productId: product.id, quantity: 1 })).unwrap() | ||
toast('❌ Removed from Cart') | ||
} else { | ||
await dispatch(addProduct({ productId: product.id, quantity: 1 })).unwrap() | ||
toast('🛒 Added to Cart') | ||
} | ||
} catch (error) { | ||
setError('An error occurred. Please try again.') | ||
toast(error instanceof Error ? error.message : '❌ Failed to update the cart') | ||
} finally { | ||
setIsLoading(false) | ||
} | ||
} |
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.
Just a heads-up: since handleClick is async, setIsLoading(false) might run after the component unmounts, which can trigger a React warning. To avoid that, it's a good idea to track if the component is still mounted before updating state
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.
@YuliyaMinsk it seems that the warning and this recommendation is gone since React 18 release: facebook/react#22114
Uh oh!
There was an error while loading. Please reload this page.