forked from TeamFirefli/firefli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.ts
More file actions
58 lines (53 loc) · 1.19 KB
/
state.ts
File metadata and controls
58 lines (53 loc) · 1.19 KB
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
import { atom, selector } from "recoil";
import Router from "next/router";
import { role } from "@prisma/client";
import axios from "axios";
export type workspaceinfo = {
groupId: number;
groupThumbnail: string;
groupName: string
}
export type LoginState = {
userId: number;
username: string;
displayname: string;
thumbnail: string;
canMakeWorkspace: boolean;
workspaces: workspaceinfo[];
isOwner: boolean;
}
const loginState = atom<LoginState>({
key: "loginState",
default: {
userId: 1,
username: '',
displayname: '',
thumbnail: '',
canMakeWorkspace: false,
workspaces: [] as workspaceinfo[],
isOwner: false
},
});
const workspacestate = atom({
key: "workspacestate",
default: {
groupId: typeof window !== 'undefined' ? parseInt(window.location.pathname.split('/')[2]) || 1 : 1,
groupThumbnail: '',
groupName: '',
yourPermission: [] as string[],
isAdmin: false,
groupTheme: '',
roles: [] as role[],
yourRole: '',
settings: {
guidesEnabled: false,
sessionsEnabled: false,
alliesEnabled: false,
noticesEnabled: false,
leaderboardEnabled: false,
policiesEnabled: false,
widgets: [] as string[]
}
}
});
export {loginState, workspacestate};