Skip to content

Commit b38625a

Browse files
authored
fix: remove featured content box if empty and not admin (#659)
1 parent 9b12a2f commit b38625a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

frontend/src/Components/dashboard/FeaturedContent.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ export default function FeaturedContent({
1414
const [expanded, setExpanded] = useState<boolean>(false);
1515
const cols = user?.role == UserRole.Student ? 3 : 4;
1616
const slice = expanded ? featured.length : cols;
17+
const isAdmin =
18+
user?.role === UserRole.Admin || user?.role === UserRole.SystemAdmin;
1719

1820
const navigate = useNavigate();
1921

2022
const handleEmptyStateClick = () => {
21-
if (
22-
user?.role === UserRole.Admin ||
23-
user?.role === UserRole.SystemAdmin
24-
) {
23+
if (isAdmin) {
2524
navigate('/knowledge-center-management/libraries', {
2625
replace: true
2726
});
2827
}
2928
};
29+
if (!featured.length && !isAdmin) {
30+
return null;
31+
}
3032

3133
return (
3234
<>

0 commit comments

Comments
 (0)