-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
91 lines (85 loc) · 3.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { getCookie } from 'cookies-next';
import { fetchWrapperOptions, getUserAppSID } from 'utils';
import { create } from 'zustand';
const getInstanceZUID = () => {
if (typeof window !== 'undefined') {
return window?.location?.pathname?.split('/')[2];
}
};
const instanceZUID = getCookie('ZESTY_WORKING_INSTANCE') || getInstanceZUID();
const userAppSID = getUserAppSID();
export const getZestyAPI = (id) => {
if (typeof window !== 'undefined') {
return new Zesty.FetchWrapper(
id || instanceZUID,
userAppSID,
fetchWrapperOptions(),
);
}
};
export const useZestyStore = create((set) => {
return {
instanceZUID,
userAppSID,
ZestyAPI: getZestyAPI(),
setZestyAPI: (data) => set(() => ({ ZestyAPI: data })),
isAuthenticated: false,
setisAuthenticated: (data) => set(() => ({ isAuthenticated: data })),
isUser: false,
setisUser: (data) => set(() => ({ isUser: data })),
workingInstance: instanceZUID,
setworkingInstance: (data) => set(() => ({ workingInstance: data })),
verifySuccess: {},
setverifySuccess: (data) => set(() => ({ verifySuccess: data })),
instances: {},
setInstances: (data) => set(() => ({ instances: data })),
instance: {},
setInstance: (data) => set(() => ({ instance: data })),
loading: false,
setloading: (data) => set(() => ({ loading: data })),
userInfo: {},
setuserInfo: (data) => set(() => ({ userInfo: data })),
prefs: {},
setprefs: (data) => set(() => ({ prefs: data })),
usage: {},
setusage: (data) => set(() => ({ usage: data })),
contentModels: [],
setcontentModels: (data) => set(() => ({ contentModels: data })),
contentModel: [],
setcontentModel: (data) => set(() => ({ contentModel: data })),
// new user data
role: '',
setrole: (data) => set(() => ({ role: data })),
userType: '',
setuserType: (data) => set(() => ({ userType: data })),
projectType: '',
setprojectType: (data) => set(() => ({ projectType: data })),
projectName: '',
setprojectName: (data) => set(() => ({ projectName: data })),
emails: [],
setemails: (data) => set(() => ({ emails: data })),
company: '',
setcompany: (data) => set(() => ({ company: data })),
phoneNumber: '',
setphoneNumber: (data) => set(() => ({ phoneNumber: data })),
projectDescription: '',
setprojectDescription: (data) => set(() => ({ projectDescription: data })),
userInvited: '',
setuserInvited: (data) => set(() => ({ userInvited: data })),
//algolia
algoliaApiKey: '',
setalgoliaApiKey: (data) => set(() => ({ algoliaApiKey: data })),
algoliaAppId: '',
setalgoliaAppId: (data) => set(() => ({ algoliaAppId: data })),
algoliaIndex: '',
setalgoliaIndex: (data) => set(() => ({ algoliaIndex: data })),
// docs
mainData: [],
setmainData: (data) => set(() => ({ mainData: data })),
language: 'Javascript',
setlanguage: (data) => set(() => ({ language: data })),
selectedDocsCategory: 'Instances',
setSelectedDocsCategory: (data) =>
set(() => ({ selectedDocsCategory: data })),
};
});