2023-07-31 11:27:28 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2023-07-28 08:09:42 +00:00
|
|
|
import Link from "next/link";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-07-28 08:09:42 +00:00
|
|
|
|
|
|
|
// components
|
2023-10-17 10:53:54 +00:00
|
|
|
import { ProfileIssuesFilter } from "components/profile";
|
2024-01-25 12:30:45 +00:00
|
|
|
// constants
|
|
|
|
import { PROFILE_ADMINS_TAB, PROFILE_VIEWER_TAB } from "constants/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-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;
|
|
|
|
|
2024-01-25 12:30:45 +00:00
|
|
|
const tabsList = isAuthorized ? [...PROFILE_VIEWER_TAB, ...PROFILE_ADMINS_TAB] : PROFILE_VIEWER_TAB;
|
2023-07-31 11:27:28 +00:00
|
|
|
|
2023-07-28 08:09:42 +00:00
|
|
|
return (
|
2024-02-08 12:19:26 +00:00
|
|
|
<div className="sticky -top-0.5 z-10 hidden md: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
|
2024-03-06 08:54:36 +00:00
|
|
|
className={`flex whitespace-nowrap border-b-2 p-4 text-sm font-medium outline-none ${
|
|
|
|
router.pathname === tab.selected
|
|
|
|
? "border-custom-primary-100 text-custom-primary-100"
|
|
|
|
: "border-transparent"
|
|
|
|
}`}
|
2023-07-28 08:09:42 +00:00
|
|
|
>
|
|
|
|
{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>
|
|
|
|
);
|
|
|
|
};
|