modalShow.ts 696 B

12345678910111213141516171819202122
  1. import { create } from "zustand";
  2. const modalList = ["WheelSection", "SignInSection", "HomePromotion"];
  3. export const useModalShow = create((set) => ({
  4. modalShow: "WheelSection",
  5. closeModalShow: (key: string) => {
  6. const idx = modalList.indexOf(key);
  7. let keyName = "";
  8. if (idx + 1 < modalList.length) {
  9. keyName = modalList[idx + 1];
  10. }
  11. if (!keyName || !modalList.includes(keyName)) return;
  12. set((state: any) => {
  13. return { ...state, modalShow: keyName || "" };
  14. });
  15. },
  16. setModalShow: (key: string) => {
  17. set((state: any) => {
  18. return { ...state, modalShow: key };
  19. });
  20. },
  21. }));