adminFront/src/stores/cart.ts

25 lines
558 B
TypeScript
Raw Normal View History

2023-03-06 13:22:12 +00:00
import { create } from "zustand";
2023-08-02 11:36:50 +00:00
import { devtools } from "zustand/middleware";
import { CartData } from "@frontend/kitui";
2023-02-18 13:59:36 +00:00
interface CartStore {
2023-08-02 11:36:50 +00:00
cartData: CartData | null;
2023-02-18 13:59:36 +00:00
}
2023-08-02 11:36:50 +00:00
const initialState: CartStore = {
cartData: null,
};
2023-02-18 13:59:36 +00:00
export const useCartStore = create<CartStore>()(
2023-08-02 11:36:50 +00:00
devtools(
(set, get) => initialState,
{
name: "Cart",
enabled: process.env.NODE_ENV === "development",
}
)
);
2023-08-02 11:36:50 +00:00
export const setCartData = (cartData: CartStore["cartData"]) => useCartStore.setState({ cartData });