2023-10-25 10:18:57 +00:00
|
|
|
// ui
|
2024-03-06 13:09:14 +00:00
|
|
|
import { FC } from "react";
|
2024-04-29 06:42:33 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-03-06 13:09:14 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { ChevronDown, PanelRight } from "lucide-react";
|
2024-02-08 12:19:26 +00:00
|
|
|
import { Breadcrumbs, CustomMenu } from "@plane/ui";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { BreadcrumbLink } from "@/components/common";
|
2024-01-30 09:52:24 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { PROFILE_ADMINS_TAB, PROFILE_VIEWER_TAB } from "@/constants/profile";
|
|
|
|
import { cn } from "@/helpers/common.helper";
|
2024-04-29 06:42:33 +00:00
|
|
|
import { useAppTheme, useUser } from "@/hooks/store";
|
2023-11-03 12:31:49 +00:00
|
|
|
|
2024-02-08 12:19:26 +00:00
|
|
|
type TUserProfileHeader = {
|
2024-03-06 13:09:14 +00:00
|
|
|
type?: string | undefined;
|
|
|
|
};
|
2024-02-08 12:19:26 +00:00
|
|
|
|
|
|
|
export const UserProfileHeader: FC<TUserProfileHeader> = observer((props) => {
|
2024-03-06 13:09:14 +00:00
|
|
|
const { type = undefined } = props;
|
2024-04-29 06:42:33 +00:00
|
|
|
// router
|
2024-02-08 12:19:26 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, userId } = router.query;
|
2024-04-29 06:42:33 +00:00
|
|
|
// store hooks
|
|
|
|
const { toggleProfileSidebar, profileSidebarCollapsed } = useAppTheme();
|
2024-02-08 12:19:26 +00:00
|
|
|
const {
|
|
|
|
membership: { currentWorkspaceRole },
|
|
|
|
} = useUser();
|
2024-04-29 06:42:33 +00:00
|
|
|
// derived values
|
|
|
|
const AUTHORIZED_ROLES = [20, 15, 10];
|
2024-02-08 12:19:26 +00:00
|
|
|
|
|
|
|
if (!currentWorkspaceRole) return null;
|
|
|
|
|
|
|
|
const isAuthorized = AUTHORIZED_ROLES.includes(currentWorkspaceRole);
|
|
|
|
const tabsList = isAuthorized ? [...PROFILE_VIEWER_TAB, ...PROFILE_ADMINS_TAB] : PROFILE_VIEWER_TAB;
|
|
|
|
|
2024-03-06 13:09:14 +00:00
|
|
|
return (
|
2024-03-18 07:20:33 +00:00
|
|
|
<div className="relative z-10 flex h-[3.75rem] w-full flex-shrink-0 flex-row items-center justify-between gap-x-2 gap-y-4 bg-custom-sidebar-background-100 p-4">
|
2024-03-06 13:09:14 +00:00
|
|
|
<div className="flex w-full flex-grow items-center gap-2 overflow-ellipsis whitespace-nowrap">
|
2024-04-29 06:42:33 +00:00
|
|
|
<div className="flex w-full justify-between">
|
2024-03-06 13:09:14 +00:00
|
|
|
<Breadcrumbs>
|
|
|
|
<Breadcrumbs.BreadcrumbItem
|
|
|
|
type="text"
|
|
|
|
link={<BreadcrumbLink href="/profile" label="Activity Overview" />}
|
|
|
|
/>
|
|
|
|
</Breadcrumbs>
|
|
|
|
<div className="flex gap-4 md:hidden">
|
|
|
|
<CustomMenu
|
|
|
|
maxHeight={"md"}
|
2024-04-29 06:42:33 +00:00
|
|
|
className="flex flex-grow justify-center text-sm text-custom-text-200"
|
2024-03-06 13:09:14 +00:00
|
|
|
placement="bottom-start"
|
|
|
|
customButton={
|
2024-04-29 06:42:33 +00:00
|
|
|
<div className="flex items-center gap-2 rounded-md border border-custom-border-400 px-2 py-1.5">
|
|
|
|
<span className="flex flex-grow justify-center text-sm text-custom-text-200">{type}</span>
|
|
|
|
<ChevronDown className="h-4 w-4 text-custom-text-400" />
|
2024-03-06 13:09:14 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
customButtonClassName="flex flex-grow justify-center text-custom-text-200 text-sm"
|
|
|
|
closeOnSelect
|
|
|
|
>
|
|
|
|
<></>
|
|
|
|
{tabsList.map((tab) => (
|
|
|
|
<CustomMenu.MenuItem className="flex items-center gap-2" key={tab.route}>
|
|
|
|
<Link
|
|
|
|
key={tab.route}
|
|
|
|
href={`/${workspaceSlug}/profile/${userId}/${tab.route}`}
|
2024-04-29 06:42:33 +00:00
|
|
|
className="w-full text-custom-text-300"
|
2024-03-06 13:09:14 +00:00
|
|
|
>
|
|
|
|
{tab.label}
|
|
|
|
</Link>
|
|
|
|
</CustomMenu.MenuItem>
|
|
|
|
))}
|
|
|
|
</CustomMenu>
|
|
|
|
<button
|
2024-04-29 06:42:33 +00:00
|
|
|
className="block transition-all md:hidden"
|
2024-03-06 13:09:14 +00:00
|
|
|
onClick={() => {
|
2024-04-29 06:42:33 +00:00
|
|
|
toggleProfileSidebar();
|
2024-03-06 13:09:14 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<PanelRight
|
|
|
|
className={cn(
|
2024-04-29 06:42:33 +00:00
|
|
|
"block h-4 w-4 md:hidden",
|
|
|
|
!profileSidebarCollapsed ? "text-[#3E63DD]" : "text-custom-text-200"
|
2024-03-06 13:09:14 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
2024-02-08 12:19:26 +00:00
|
|
|
</div>
|
2023-10-25 10:18:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-06 13:09:14 +00:00
|
|
|
);
|
2024-02-08 12:19:26 +00:00
|
|
|
});
|