27 lines
718 B
TypeScript
27 lines
718 B
TypeScript
![]() |
import create from "zustand";
|
||
|
import { devtools, persist } from "zustand/middleware";
|
||
|
import { Promocode } from "../model/cart";
|
||
|
|
||
|
|
||
|
interface PromocodeStore {
|
||
|
promocodeArray: Array<Promocode>,
|
||
|
setPromocodeArray: (array: Array<Promocode>) => void,
|
||
|
}
|
||
|
|
||
|
export const usePromocodeStore = create<PromocodeStore>()(
|
||
|
devtools(
|
||
|
persist(
|
||
|
(set, get) => ({
|
||
|
promocodeArray: [],
|
||
|
setPromocodeArray: (array: Array<Promocode>) => set({ promocodeArray: array }),
|
||
|
}),
|
||
|
{
|
||
|
name: "promocode-storage",
|
||
|
getStorage: () => localStorage,
|
||
|
}
|
||
|
),
|
||
|
{
|
||
|
name: "Promocode store"
|
||
|
}
|
||
|
)
|
||
|
);
|