12345678910111213141516171819202122 |
- import { create } from "zustand";
- const modalList = ["WheelSection", "SignInSection", "HomePromotion"];
- export const useModalShow = create((set) => ({
- modalShow: "WheelSection",
- closeModalShow: (key: string) => {
- const idx = modalList.indexOf(key);
- let keyName = "";
- if (idx + 1 < modalList.length) {
- keyName = modalList[idx + 1];
- }
- if (!keyName || !modalList.includes(keyName)) return;
- set((state: any) => {
- return { ...state, modalShow: keyName || "" };
- });
- },
- setModalShow: (key: string) => {
- set((state: any) => {
- return { ...state, modalShow: key };
- });
- },
- }));
|