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 = () => {
35
35
const [ updateCart ] = useMutation ( UPDATE_CART ) ;
36
36
37
37
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 ) ;
50
40
51
41
// Update remote state in background
52
42
updateCart ( {
You can’t perform that action at this time.
0 commit comments