adminFront/src/stores/promocodes.ts

28 lines
783 B
TypeScript
Raw Normal View History

2023-02-18 13:59:36 +00:00
import create from "zustand";
import { devtools, persist } from "zustand/middleware";
import { Promocode } from "../model/cart";
2023-02-20 11:49:35 +00:00
import { testPromocodes } from "./mocks/promocodes";
2023-02-18 13:59:36 +00:00
interface PromocodeStore {
promocodeArray: Array<Promocode>,
setPromocodeArray: (array: Array<Promocode>) => void,
}
export const usePromocodeStore = create<PromocodeStore>()(
devtools(
persist(
(set, get) => ({
2023-02-20 11:49:35 +00:00
promocodeArray: testPromocodes,
2023-02-18 13:59:36 +00:00
setPromocodeArray: (array: Array<Promocode>) => set({ promocodeArray: array }),
}),
{
name: "promocode-storage",
getStorage: () => localStorage,
}
),
{
name: "Promocode store"
}
)
);