forked from github/plane
fix: profile layout flicker (#2898)
* fix: user profile layout flicker * chore: update import statements
This commit is contained in:
parent
3203ae6549
commit
f48cd6f50c
@ -1,11 +1,8 @@
|
|||||||
import useSWR from "swr";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useRouter } from "next/router";
|
// mobx store
|
||||||
// services
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
import { WorkspaceService } from "services/workspace.service";
|
|
||||||
// components
|
// components
|
||||||
import { ProfileNavbar, ProfileSidebar } from "components/profile";
|
import { ProfileNavbar, ProfileSidebar } from "components/profile";
|
||||||
// constants
|
|
||||||
import { WORKSPACE_MEMBERS_ME } from "constants/fetch-keys";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@ -13,21 +10,18 @@ type Props = {
|
|||||||
showProfileIssuesFilter?: boolean;
|
showProfileIssuesFilter?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// services
|
const AUTHORIZED_ROLES = [20, 15, 10];
|
||||||
const workspaceService = new WorkspaceService();
|
|
||||||
|
|
||||||
export const ProfileAuthWrapper: React.FC<Props> = (props) => {
|
export const ProfileAuthWrapper: React.FC<Props> = observer((props) => {
|
||||||
const { children, className, showProfileIssuesFilter } = props;
|
const { children, className, showProfileIssuesFilter } = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const {
|
||||||
const { workspaceSlug } = router.query;
|
user: { currentWorkspaceRole },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
const { data: memberDetails } = useSWR(
|
if (!currentWorkspaceRole) return null;
|
||||||
workspaceSlug ? WORKSPACE_MEMBERS_ME(workspaceSlug.toString()) : null,
|
|
||||||
workspaceSlug ? () => workspaceService.workspaceMemberMe(workspaceSlug.toString()) : null
|
|
||||||
);
|
|
||||||
|
|
||||||
const isAuthorized = memberDetails?.role === 20 || memberDetails?.role === 15 || memberDetails?.role === 10;
|
const isAuthorized = AUTHORIZED_ROLES.includes(currentWorkspaceRole);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full w-full md:flex md:flex-row-reverse md:overflow-hidden">
|
<div className="h-full w-full md:flex md:flex-row-reverse md:overflow-hidden">
|
||||||
@ -44,4 +38,4 @@ export const ProfileAuthWrapper: React.FC<Props> = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user