🔥 Finish Cart implementation

- Use Select component in CartItem to change quantity
- Visual update when removing or changing an item quantity
- API: Remove Cart item action
- API: Handle Cart item adding and updating (quantity)
This commit is contained in:
2021-11-07 20:21:20 +01:00
parent e1c259164f
commit f7457b5f8d
8 changed files with 290 additions and 105 deletions

View File

@@ -1,4 +1,4 @@
import { addToCart, createCart, fetchCart, getProduct, updateCartItem } from '$utils/swellFunctions'
import { addToCart, createCart, fetchCart, getProduct, removeCartItem, updateCartItem } from '$utils/swellFunctions'
// Block GET requests
@@ -41,11 +41,13 @@ export async function post ({ headers, query, body, params, ...rest }) {
result = await updateCartItem(cartId, productId, bodyParsed.quantity)
break
}
case 'removeCartItem': {
result = await removeCartItem(cartId, productId)
break
}
default: break
}
}
return {
status: 200,
body: result,