summaryrefslogtreecommitdiff
path: root/src-migrate/modules/product-promo/stores/useModalStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/product-promo/stores/useModalStore.ts')
-rw-r--r--src-migrate/modules/product-promo/stores/useModalStore.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/src-migrate/modules/product-promo/stores/useModalStore.ts b/src-migrate/modules/product-promo/stores/useModalStore.ts
new file mode 100644
index 00000000..bbb2b1fb
--- /dev/null
+++ b/src-migrate/modules/product-promo/stores/useModalStore.ts
@@ -0,0 +1,28 @@
+import { create } from 'zustand';
+import { CategoryPromo } from '~/common/types/promotion';
+
+type State = {
+ active: boolean;
+ variantId?: number;
+ activeTab: CategoryPromo;
+};
+
+type Action = {
+ openModal: (variantId: number) => void;
+ closeModal: () => void;
+ changeTab: (tab: State['activeTab']) => void;
+};
+
+const defaultState: Omit<State, 'activeTab'> = {
+ active: false,
+ variantId: undefined,
+};
+
+export const useModalStore = create<State & Action>((set) => ({
+ ...defaultState,
+ activeTab: 'bundling',
+ openModal: (variantId: number) => set({ active: true, variantId }),
+ closeModal: () => set(defaultState),
+ // TABS
+ changeTab: (tab) => set({ activeTab: tab }),
+}));