feat(saleor): Phase 3 - Cart Migration

- Create Saleor checkout store (Zustand + persist)
- Update CartDrawer to use Saleor checkout
- Update Header to use Saleor checkout store
- Update ProductDetail with Add to Cart functionality
- Add checkout initialization on app load
- Handle checkout line add/update/delete operations
- Add error handling and loading states
This commit is contained in:
Unchained
2026-03-21 12:42:41 +02:00
parent 5706792980
commit 8b3389725e
4 changed files with 482 additions and 96 deletions

View File

@@ -1,19 +1,24 @@
"use client";
import { useState } from "react";
import { useState, useEffect } from "react";
import Link from "next/link";
import Image from "next/image";
import { AnimatePresence } from "framer-motion";
import { useCartStore } from "@/stores/cartStore";
import { useSaleorCheckoutStore } from "@/stores/saleorCheckoutStore";
import { User, ShoppingBag, Menu } from "lucide-react";
import MobileMenu from "./MobileMenu";
import CartDrawer from "@/components/cart/CartDrawer";
export default function Header() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const { items, toggleCart } = useCartStore();
const { getLineCount, toggleCart, initCheckout } = useSaleorCheckoutStore();
const itemCount = items.reduce((count, item) => count + item.quantity, 0);
const itemCount = getLineCount();
// Initialize checkout on mount
useEffect(() => {
initCheckout();
}, [initCheckout]);
return (
<>