'use client'; import { useEffect, useState } from 'react'; import Link from 'next/link'; import { useCart } from '@/lib/cartStore'; import { getColorName } from '@/lib/colorNames'; import Price from '@/components/Price'; export default function CartPage() { const [mounted, setMounted] = useState(false); const items = useCart((s) => s.items); const removeItem = useCart((s) => s.removeItem); const setQuantity = useCart((s) => s.setQuantity); const total = useCart((s) => s.total()); const hasCustomDesign = items.some((item) => { try { const design = typeof item.designJson === 'string' ? JSON.parse(item.designJson) : item.designJson; return (design.front?.length ?? 0) > 0 || (design.back?.length ?? 0) > 0; } catch { return false; } }); useEffect(() => setMounted(true), []); const handleCheckout = () => { // Set flag so LogoutOnUnload doesn't clear cart during navigation to checkout if (typeof window !== 'undefined') { sessionStorage.setItem('isCheckingOut', 'true'); console.log('💳 Cart checkout button clicked - set isCheckingOut flag'); } window.location.href = '/checkout'; }; if (!mounted) return null; if (items.length === 0) { return (
Nothing in here yet.
{item.name}
Custom design {hasFront && hasBack ? ' — front & back' : hasBack ? ' — back' : ' — front'}
Please check your design before checking out
We print exactly what's shown in your preview above — spelling, wording, and approximate placement included. Once your order's placed, that design goes straight to print, so take a moment to make sure everything looks right.
You'll enter payment details on the next step.
By placing an order you agree to our{' '} Terms {' '} and{' '} Returns policy .