el.xwx.moe/store/modals.ts

62 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-06-12 23:46:32 -05:00
import {
AccountSettings,
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: "ACCOUNT";
state: boolean;
active: AccountSettings;
defaultIndex?: number;
}
| {
modal: "LINK";
state: boolean;
method: "CREATE";
2023-06-24 16:54:35 -05:00
isOwnerOrMod?: boolean;
active?: LinkIncludingShortenedCollectionAndTags;
defaultIndex?: number;
2023-06-12 23:46:32 -05:00
}
| {
modal: "LINK";
state: boolean;
method: "UPDATE";
2023-06-24 16:54:35 -05:00
isOwnerOrMod: boolean;
active: LinkIncludingShortenedCollectionAndTags;
defaultIndex?: number;
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-06-12 23:46:32 -05:00
| null;
type ModalsStore = {
modal: Modal;
setModal: (modal: Modal) => void;
};
const useLocalSettingsStore = create<ModalsStore>((set) => ({
modal: null,
setModal: (modal: Modal) => {
set({ modal });
},
}));
export default useLocalSettingsStore;