fix: workspace members store added and implemented across the app (#2732)
* fix: minor changes * fix: workspace members store added and implemnted across the app
This commit is contained in:
parent
556b2d2617
commit
a6567bbce4
28 changed files with 529 additions and 352 deletions
|
|
@ -13,19 +13,22 @@ export interface IUserAuthWrapper {
|
|||
export const UserAuthWrapper: FC<IUserAuthWrapper> = (props) => {
|
||||
const { children } = props;
|
||||
// store
|
||||
const { user: userStore, workspace: workspaceStore } = useMobxStore();
|
||||
const {
|
||||
user: { fetchCurrentUser, fetchCurrentUserSettings },
|
||||
workspace: { fetchWorkspaces },
|
||||
} = useMobxStore();
|
||||
// router
|
||||
const router = useRouter();
|
||||
// fetching user information
|
||||
const { data: currentUser, error } = useSWR("CURRENT_USER_DETAILS", () => userStore.fetchCurrentUser(), {
|
||||
const { data: currentUser, error } = useSWR("CURRENT_USER_DETAILS", () => fetchCurrentUser(), {
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
// fetching user settings
|
||||
useSWR("CURRENT_USER_SETTINGS", () => userStore.fetchCurrentUserSettings(), {
|
||||
useSWR("CURRENT_USER_SETTINGS", () => fetchCurrentUserSettings(), {
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
// fetching all workspaces
|
||||
useSWR(`USER_WORKSPACES_LIST`, () => workspaceStore.fetchWorkspaces(), {
|
||||
useSWR(`USER_WORKSPACES_LIST`, () => fetchWorkspaces(), {
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,30 +15,35 @@ export interface IWorkspaceAuthWrapper {
|
|||
export const WorkspaceAuthWrapper: FC<IWorkspaceAuthWrapper> = observer((props) => {
|
||||
const { children } = props;
|
||||
// store
|
||||
const { user: userStore, project: projectStore, workspace: workspaceStore } = useMobxStore();
|
||||
const { currentWorkspaceMemberInfo, hasPermissionToCurrentWorkspace } = userStore;
|
||||
const {
|
||||
user: { currentWorkspaceMemberInfo, hasPermissionToCurrentWorkspace, fetchUserWorkspaceInfo },
|
||||
project: { fetchProjects },
|
||||
workspace: { fetchWorkspaceLabels },
|
||||
workspaceMember: { fetchWorkspaceMembers },
|
||||
} = useMobxStore();
|
||||
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
// fetching user workspace information
|
||||
useSWR(
|
||||
workspaceSlug ? `WORKSPACE_MEMBERS_ME_${workspaceSlug}` : null,
|
||||
workspaceSlug ? () => userStore.fetchUserWorkspaceInfo(workspaceSlug.toString()) : null
|
||||
workspaceSlug ? () => fetchUserWorkspaceInfo(workspaceSlug.toString()) : null
|
||||
);
|
||||
// fetching workspace projects
|
||||
useSWR(
|
||||
workspaceSlug ? `WORKSPACE_PROJECTS_${workspaceSlug}` : null,
|
||||
workspaceSlug ? () => projectStore.fetchProjects(workspaceSlug.toString()) : null
|
||||
workspaceSlug ? () => fetchProjects(workspaceSlug.toString()) : null
|
||||
);
|
||||
// fetch workspace members
|
||||
useSWR(
|
||||
workspaceSlug ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null,
|
||||
workspaceSlug ? () => workspaceStore.fetchWorkspaceMembers(workspaceSlug.toString()) : null
|
||||
workspaceSlug ? () => fetchWorkspaceMembers(workspaceSlug.toString()) : null
|
||||
);
|
||||
// fetch workspace labels
|
||||
useSWR(
|
||||
workspaceSlug ? `WORKSPACE_LABELS_${workspaceSlug}` : null,
|
||||
workspaceSlug ? () => workspaceStore.fetchWorkspaceLabels(workspaceSlug.toString()) : null
|
||||
workspaceSlug ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null
|
||||
);
|
||||
|
||||
// while data is being loaded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue