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 {
|
2023-06-06 11:27:49 +00:00
|
|
|
cartTotal: CartTotal | null;
|
|
|
|
setCartTotal: (newCartTotal: CartTotal | null) => void;
|
2023-02-18 13:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const useCartStore = create<CartStore>()(
|
2023-06-06 11:27:49 +00:00
|
|
|
devtools(
|
|
|
|
// persist(
|
|
|
|
(set, get) => ({
|
|
|
|
cartTotal: null,
|
|
|
|
setCartTotal: (newCartTotal) => set({ cartTotal: newCartTotal }),
|
|
|
|
}),
|
|
|
|
// {
|
|
|
|
// name: "cart",
|
|
|
|
// getStorage: () => localStorage,
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
{
|
|
|
|
name: "Cart store",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|