2023-06-12 23:46:32 -05:00
|
|
|
import {
|
|
|
|
AccountSettings,
|
2023-06-16 07:55:21 -05:00
|
|
|
CollectionIncludingMembersAndLinkCount,
|
2023-06-14 17:34:54 -05:00
|
|
|
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 08:17:24 -05:00
|
|
|
isOwner?: boolean;
|
2023-06-14 17:34:54 -05:00
|
|
|
active?: LinkIncludingShortenedCollectionAndTags;
|
2023-06-20 09:39:03 -05:00
|
|
|
defaultIndex?: number;
|
2023-06-12 23:46:32 -05:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
modal: "LINK";
|
|
|
|
state: boolean;
|
|
|
|
method: "UPDATE";
|
2023-06-24 08:17:24 -05:00
|
|
|
isOwner: boolean;
|
2023-06-14 17:34:54 -05:00
|
|
|
active: LinkIncludingShortenedCollectionAndTags;
|
2023-06-20 09:39:03 -05:00
|
|
|
defaultIndex?: number;
|
2023-06-12 23:46:32 -05:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
modal: "COLLECTION";
|
|
|
|
state: boolean;
|
2023-06-18 00:27:57 -05:00
|
|
|
method: "UPDATE";
|
2023-06-22 09:35:02 -05:00
|
|
|
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-22 09:35:02 -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;
|