adminFront/src/stores/cart.ts

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