File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change @@ -35,18 +35,8 @@ const CartContents = () => {
3535 const [ updateCart ] = useMutation ( UPDATE_CART ) ;
3636
3737 const handleRemoveProductClick = ( cartKey : string ) => {
38- // Optimistically update local state
39- if ( cart ) {
40- const updatedProducts = cart . products . filter ( ( p : Product ) => p . cartKey !== cartKey ) ;
41- const removedProduct = cart . products . find ( ( p : Product ) => p . cartKey === cartKey ) ;
42- const qtyRemoved = removedProduct ?. qty || 0 ;
43-
44- setCart ( {
45- ...cart ,
46- products : updatedProducts ,
47- totalProductsCount : cart . totalProductsCount - qtyRemoved
48- } ) ;
49- }
38+ // Update local state
39+ useCartStore . getState ( ) . removeProduct ( cartKey ) ;
5040
5141 // Update remote state in background
5242 updateCart ( {
You can’t perform that action at this time.
0 commit comments