el.xwx.moe/store/modals.ts

65 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-06-12 23:46:32 -05:00
import {
2023-06-16 07:55:21 -05:00
CollectionIncludingMembersAndLinkCount,
LinkIncludingShortenedCollectionAndTags,
2023-06-12 23:46:32 -05:00
} from "@/types/global";
import { create } from "zustand";
type Modal =
| {
modal: "LINK";
state: boolean;
method: "CREATE";
active?: LinkIncludingShortenedCollectionAndTags;
2023-06-12 23:46:32 -05:00
}
| {
modal: "LINK";
state: boolean;
method: "UPDATE";
active: LinkIncludingShortenedCollectionAndTags;
2023-10-30 14:20:15 -05:00
}
| {
modal: "LINK";
state: boolean;
method: "FORMATS";
active: LinkIncludingShortenedCollectionAndTags;
2023-06-12 23:46:32 -05:00
}
| {
modal: "COLLECTION";
state: boolean;
2023-06-18 00:27:57 -05:00
method: "UPDATE";
isOwner: boolean;
2023-06-16 07:55:21 -05:00
active: CollectionIncludingMembersAndLinkCount;
2023-06-12 23:46:32 -05:00
defaultIndex?: number;
}
2023-06-18 00:27:57 -05:00
| {
modal: "COLLECTION";
state: boolean;
method: "CREATE";
2023-06-24 16:54:35 -05:00
isOwner?: boolean;
2023-06-18 00:27:57 -05:00
active?: CollectionIncludingMembersAndLinkCount;
defaultIndex?: number;
}
2023-11-15 22:31:13 -06:00
| {
modal: "COLLECTION";
state: boolean;
method: "VIEW_TEAM";
isOwner?: boolean;
active?: CollectionIncludingMembersAndLinkCount;
defaultIndex?: number;
}
2023-06-12 23:46:32 -05:00
| null;
type ModalsStore = {
modal: Modal;
setModal: (modal: Modal) => void;
};
2023-11-15 22:31:13 -06:00
const useModalStore = create<ModalsStore>((set) => ({
2023-06-12 23:46:32 -05:00
modal: null,
setModal: (modal: Modal) => {
set({ modal });
},
}));
2023-11-15 22:31:13 -06:00
export default useModalStore;