27 lines
680 B
TypeScript
27 lines
680 B
TypeScript
import { create } from "zustand";
|
|
import { devtools, persist } from "zustand/middleware";
|
|
import { CartTotal } from "@root/model/cart";
|
|
|
|
|
|
interface CartStore {
|
|
cartTotal: CartTotal | null;
|
|
setCartTotal: (newCartTotal: CartTotal) => void;
|
|
}
|
|
|
|
export const useCartStore = create<CartStore>()(
|
|
devtools(
|
|
// persist(
|
|
(set, get) => ({
|
|
cartTotal: null,
|
|
setCartTotal: newCartTotal => set({ cartTotal: newCartTotal })
|
|
}),
|
|
// {
|
|
// name: "cart",
|
|
// getStorage: () => localStorage,
|
|
// }
|
|
// ),
|
|
{
|
|
name: "Cart store"
|
|
}
|
|
)
|
|
); |