Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/expert-finder/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export default function ExpertFinderLayout({ children }: ExpertFinderLayoutProps
const { user, isLoading } = useUser();
const router = useRouter();
const isModerator = !!user?.isModerator;
const isHubEditor = !!user?.authorProfile?.isHubEditor;
const canAccessExpertFinder = isModerator || isHubEditor;

useEffect(() => {
if (!isLoading && !isModerator) {
if (!isLoading && !canAccessExpertFinder) {
router.push('/popular');
}
}, [isLoading, isModerator, router]);
}, [isLoading, canAccessExpertFinder, router]);

if (isLoading) {
return (
Expand All @@ -36,7 +38,7 @@ export default function ExpertFinderLayout({ children }: ExpertFinderLayoutProps
);
}

if (!isModerator) {
if (!canAccessExpertFinder) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions components/menus/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function UserMenu({
</Link>
)}

{user?.isModerator && (
{(user?.isModerator || user?.authorProfile?.isHubEditor) && (
<Link href="/expert-finder" className="block" onClick={() => setMenuOpenState(false)}>
<div className="px-6 py-2 hover:bg-gray-50">
<div className="flex items-center">
Expand Down Expand Up @@ -395,7 +395,7 @@ export default function UserMenu({
</Link>
)}

{user?.isModerator && (
{(user?.isModerator || user?.authorProfile?.isHubEditor) && (
<Link href="/expert-finder" className="block" onClick={() => setMenuOpenState(false)}>
<div className="w-full px-4 py-2 hover:bg-gray-50">
<div className="flex items-center">
Expand Down
2 changes: 1 addition & 1 deletion components/work/WorkPrimaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export const WorkPrimaryActions = ({
<span>Download PDF</span>
</BaseMenuItem>
)}
{isModerator && work.unifiedDocumentId != null && (
{(isModerator || isHubEditor) && work.unifiedDocumentId != null && (
<BaseMenuItem
onSelect={() =>
router.push(
Expand Down