Skip to content
Snippets Groups Projects
Commit 003a2ead authored by ALMAZROUEI Shamma (2021) WKIS203's avatar ALMAZROUEI Shamma (2021) WKIS203
Browse files

Fix checkout issue

parent bf496f4a
Branches
No related tags found
No related merge requests found
...@@ -53,14 +53,16 @@ export default function Checkout() { ...@@ -53,14 +53,16 @@ export default function Checkout() {
email: user.email || '', email: user.email || '',
})); }));
} }
}, [initializeCart, isAuthenticated, user, navigate]);
if (cart.length === 0) { useEffect(() => {
if (isAuthenticated && cart.length === 0) {
toast.error('Cart is empty!', { toast.error('Cart is empty!', {
description: 'Please add items to your cart before checking out.', description: 'Please add items to your cart before checking out.',
}); });
navigate('/menu'); navigate('/menu');
} }
}, [cart.length, initializeCart, isAuthenticated, user, navigate]); }, [cart.length, isAuthenticated, navigate]);
// If not authenticated, don't render the checkout content // If not authenticated, don't render the checkout content
if (!isAuthenticated) { if (!isAuthenticated) {
...@@ -147,7 +149,9 @@ export default function Checkout() { ...@@ -147,7 +149,9 @@ export default function Checkout() {
setIsSubmitting(false); setIsSubmitting(false);
navigate(`/confirmation?orderId=${orderId}`); navigate(`/confirmation?orderId=${orderId}`);
clearCart(); setTimeout(() => {
clearCart();
}, 500);
}, 1500); }, 1500);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment