2023-11-27 12:55:16 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-10-25 10:18:57 +00:00
|
|
|
// components
|
|
|
|
import { ProfileNavbar, ProfileSidebar } from "components/profile";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
children: React.ReactNode;
|
|
|
|
className?: string;
|
2023-11-02 10:55:44 +00:00
|
|
|
showProfileIssuesFilter?: boolean;
|
2023-10-25 10:18:57 +00:00
|
|
|
};
|
|
|
|
|
2023-11-27 12:55:16 +00:00
|
|
|
const AUTHORIZED_ROLES = [20, 15, 10];
|
2023-10-25 10:18:57 +00:00
|
|
|
|
2023-11-27 12:55:16 +00:00
|
|
|
export const ProfileAuthWrapper: React.FC<Props> = observer((props) => {
|
2023-11-02 10:55:44 +00:00
|
|
|
const { children, className, showProfileIssuesFilter } = props;
|
|
|
|
|
2023-11-27 12:55:16 +00:00
|
|
|
const {
|
|
|
|
user: { currentWorkspaceRole },
|
|
|
|
} = useMobxStore();
|
2023-10-25 10:18:57 +00:00
|
|
|
|
2023-11-27 12:55:16 +00:00
|
|
|
if (!currentWorkspaceRole) return null;
|
2023-10-25 10:18:57 +00:00
|
|
|
|
2023-11-27 12:55:16 +00:00
|
|
|
const isAuthorized = AUTHORIZED_ROLES.includes(currentWorkspaceRole);
|
2023-10-25 10:18:57 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="h-full w-full md:flex md:flex-row-reverse md:overflow-hidden">
|
|
|
|
<ProfileSidebar />
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex w-full flex-col md:h-full md:overflow-hidden">
|
2023-11-02 10:55:44 +00:00
|
|
|
<ProfileNavbar isAuthorized={isAuthorized} showProfileIssuesFilter={showProfileIssuesFilter} />
|
2023-10-25 10:18:57 +00:00
|
|
|
{isAuthorized ? (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className={`w-full overflow-hidden md:h-full ${className}`}>{children}</div>
|
2023-10-25 10:18:57 +00:00
|
|
|
) : (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="grid h-full w-full place-items-center text-custom-text-200">
|
2023-10-25 10:18:57 +00:00
|
|
|
You do not have the permission to access this page.
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-11-27 12:55:16 +00:00
|
|
|
});
|