2023-07-31 11:27:28 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2023-07-28 08:09:42 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import Link from "next/link";
|
|
|
|
|
|
|
|
// components
|
2023-10-17 10:53:54 +00:00
|
|
|
import { ProfileIssuesFilter } from "components/profile";
|
2023-07-31 11:27:28 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-10-25 10:18:57 +00:00
|
|
|
isAuthorized: boolean;
|
2023-11-02 10:55:44 +00:00
|
|
|
showProfileIssuesFilter?: boolean;
|
2023-07-31 11:27:28 +00:00
|
|
|
};
|
2023-07-28 08:09:42 +00:00
|
|
|
|
2023-07-31 11:27:28 +00:00
|
|
|
const viewerTabs = [
|
2023-07-28 08:09:42 +00:00
|
|
|
{
|
|
|
|
route: "",
|
2023-11-20 15:16:15 +00:00
|
|
|
label: "Summary",
|
2023-07-28 08:09:42 +00:00
|
|
|
selected: "/[workspaceSlug]/profile/[userId]",
|
|
|
|
},
|
2023-07-31 11:27:28 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
const adminTabs = [
|
2023-07-28 08:09:42 +00:00
|
|
|
{
|
|
|
|
route: "assigned",
|
|
|
|
label: "Assigned",
|
|
|
|
selected: "/[workspaceSlug]/profile/[userId]/assigned",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: "created",
|
|
|
|
label: "Created",
|
|
|
|
selected: "/[workspaceSlug]/profile/[userId]/created",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: "subscribed",
|
|
|
|
label: "Subscribed",
|
|
|
|
selected: "/[workspaceSlug]/profile/[userId]/subscribed",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-11-02 10:55:44 +00:00
|
|
|
export const ProfileNavbar: React.FC<Props> = (props) => {
|
|
|
|
const { isAuthorized, showProfileIssuesFilter } = props;
|
|
|
|
|
2023-07-28 08:09:42 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, userId } = router.query;
|
|
|
|
|
2023-10-25 10:18:57 +00:00
|
|
|
const tabsList = isAuthorized ? [...viewerTabs, ...adminTabs] : viewerTabs;
|
2023-07-31 11:27:28 +00:00
|
|
|
|
2023-07-28 08:09:42 +00:00
|
|
|
return (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="sticky -top-0.5 z-10 flex items-center justify-between gap-4 border-b border-custom-border-300 bg-custom-background-100 px-4 sm:px-5 md:static">
|
2023-07-28 08:09:42 +00:00
|
|
|
<div className="flex items-center overflow-x-scroll">
|
|
|
|
{tabsList.map((tab) => (
|
|
|
|
<Link key={tab.route} href={`/${workspaceSlug}/profile/${userId}/${tab.route}`}>
|
2023-11-29 15:02:10 +00:00
|
|
|
<span
|
2023-12-10 10:18:10 +00:00
|
|
|
className={`flex whitespace-nowrap border-b-2 p-4 text-sm font-medium outline-none ${
|
2023-07-28 08:09:42 +00:00
|
|
|
router.pathname === tab.selected
|
|
|
|
? "border-custom-primary-100 text-custom-primary-100"
|
|
|
|
: "border-transparent"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{tab.label}
|
2023-11-29 15:02:10 +00:00
|
|
|
</span>
|
2023-07-28 08:09:42 +00:00
|
|
|
</Link>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-11-02 10:55:44 +00:00
|
|
|
{showProfileIssuesFilter && <ProfileIssuesFilter />}
|
2023-07-28 08:09:42 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|