2023-06-16 20:09:56 +00:00
|
|
|
import { AnyDiscount } from "@root/model/discount";
|
|
|
|
import { create } from "zustand";
|
|
|
|
import { devtools } from "zustand/middleware";
|
|
|
|
|
|
|
|
|
2023-07-10 20:22:06 +00:00
|
|
|
interface DiscountStore {
|
2023-06-16 20:09:56 +00:00
|
|
|
discounts: AnyDiscount[];
|
|
|
|
}
|
|
|
|
|
2023-07-10 20:22:06 +00:00
|
|
|
export const useDiscountStore = create<DiscountStore>()(
|
2023-06-16 20:09:56 +00:00
|
|
|
devtools(
|
|
|
|
(set, get) => ({
|
2023-07-09 23:04:23 +00:00
|
|
|
discounts: []
|
2023-06-16 20:09:56 +00:00
|
|
|
}),
|
|
|
|
{
|
2023-06-30 15:28:10 +00:00
|
|
|
name: "Discounts",
|
2023-06-16 20:09:56 +00:00
|
|
|
enabled: process.env.NODE_ENV === "development",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2023-07-10 20:22:06 +00:00
|
|
|
export const setDiscounts = (discounts: AnyDiscount[]) => useDiscountStore.setState({ discounts });
|