Improve cart and dark mode UX

- Clear cart when customer logs out
- Hide cart bag button for non-authenticated users (only show for logged-in customers)
- Fix dark mode text visibility in all form inputs (input/textarea/select elements)

Addresses user request: cart should clear on logout and only be accessible to logged-in customers.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-17 22:47:43 +01:00
co-authored by Claude Haiku 4.5
parent c8dc3467f9
commit 0cc072fda4
4 changed files with 13 additions and 6 deletions
+6 -1
View File
@@ -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;
}