diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx
index dc0869a..9669759 100644
--- a/src/app/cart/page.tsx
+++ b/src/app/cart/page.tsx
@@ -20,7 +20,7 @@ export default function CartPage() {
window.location.href = '/checkout';
};
- if (!mounted) return null; // avoid a hydration mismatch on first paint
+ if (!mounted) return null;
if (items.length === 0) {
return (
@@ -163,9 +163,6 @@ export default function CartPage() {
-
- Your cart will be saved. You can log in or continue as a guest to complete your order.
-
-
+ {customer && }
diff --git a/src/components/LogoutOnUnload.tsx b/src/components/LogoutOnUnload.tsx
index 8d1ecec..47d4879 100644
--- a/src/components/LogoutOnUnload.tsx
+++ b/src/components/LogoutOnUnload.tsx
@@ -1,14 +1,19 @@
'use client';
import { useEffect } from 'react';
+import { useCart } from '@/lib/cartStore';
/**
* Logs out the user when they close/leave the page
* Works for both admin and customer sessions
*/
export default function LogoutOnUnload() {
+ const clearCart = useCart((s) => s.clear);
+
useEffect(() => {
const handleUnload = () => {
+ // Clear cart on logout
+ clearCart();
// Use sendBeacon to reliably send logout even when page is closing
// This doesn't wait for a response, which is fine for logout
navigator.sendBeacon('/api/logout');
@@ -21,7 +26,7 @@ export default function LogoutOnUnload() {
window.removeEventListener('beforeunload', handleUnload);
window.removeEventListener('unload', handleUnload);
};
- }, []);
+ }, [clearCart]);
return null;
}