adminFront/src/stores/cart.ts

27 lines
609 B
TypeScript
Raw Normal View History

2023-03-06 13:22:12 +00:00
import { create } from "zustand";
2023-02-18 13:59:36 +00:00
import { devtools, persist } from "zustand/middleware";
2023-03-06 13:22:12 +00:00
import { CartTotal } from "@root/model/cart";
2023-02-18 13:59:36 +00:00
interface CartStore {
cartTotal: CartTotal | null;
setCartTotal: (newCartTotal: CartTotal | null) => void;
2023-02-18 13:59:36 +00:00
}
export const useCartStore = create<CartStore>()(
devtools(
// persist(
(set, get) => ({
cartTotal: null,
setCartTotal: (newCartTotal) => set({ cartTotal: newCartTotal }),
}),
// {
// name: "cart",
// getStorage: () => localStorage,
// }
// ),
{
name: "Cart store",
}
)
);