Skip to content

Commit

Permalink
Fix checkout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Oct 10, 2024
1 parent 8a0aa16 commit 2f3ae04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const CheckoutSession = () => {
const _success = status === 200

if (_success) {
await CartService.clearCart()
await CartService.deleteCartId()
setCartItemCount(0)
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/(pages)/(public)/checkout/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ const Checkout: React.FC = () => {
const _status = await CartService.clearCart(cart!._id)

if (_status === 200) {
await CartService.clearCart()
await CartService.deleteCartId()
setCartItemCount(0)
setSuccess(true)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/CartService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export const deleteItem = async (cartId: string, productId: string): Promise<wex
* @param {string} cartId
* @returns {Promise<number>}
*/
export const clearCart = async (cartId: string): Promise<number> => (
export const clearCart = async (cartId?: string): Promise<number> => (
fetchInstance
.DELETE(
`/api/delete-cart/${cartId}`,
`/api/delete-cart/${cartId || (await getCartId())}`,
[],
true
)
Expand Down

0 comments on commit 2f3ae04

Please sign in to comment.