-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCourseSidebarNav.tsx
More file actions
141 lines (133 loc) · 4.98 KB
/
CourseSidebarNav.tsx
File metadata and controls
141 lines (133 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import { useContext } from "react";
import { Segment, Menu, Image, Icon, Label } from "semantic-ui-react";
import { useRouter } from "next/router";
import Link from "next/link";
import { AuthUserContext } from "../../context/auth";
import { useStaff } from "../../hooks/data-fetching/course";
import { Course } from "../../types";
interface CourseSidebarProps {
course: Course;
}
const CourseSidebarNav = (props: CourseSidebarProps) => {
const { course } = props;
const courseId = course.id;
const { user: initialUser } = useContext(AuthUserContext);
if (!initialUser) {
throw new Error(
"Invariant broken, withAuth must be used with component"
);
}
const { leader, staff } = useStaff(courseId, initialUser);
const noWrapStyle = {
whiteSpace: "nowrap",
textOverflow: "ellipsis",
overflow: "hidden",
};
const router = useRouter();
return (
<Segment basic>
<Link href="/" as="/" legacyBehavior>
<Image
src="../../../ohq.png"
size="tiny"
style={{ marginTop: "10px", cursor: "pointer" }}
/>
</Link>
<Menu vertical secondary fluid>
{!course.archived && (
<Link
href="/courses/[course]"
as={`/courses/${courseId}`}
legacyBehavior
>
<Menu.Item
style={noWrapStyle}
name="Queues"
icon="hourglass one"
active={router.pathname.endsWith("[course]")}
color="blue"
/>
</Link>
)}
{staff && (
<Link
href="/courses/[course]/roster"
as={`/courses/${courseId}/roster`}
legacyBehavior
>
<Menu.Item
style={noWrapStyle}
name="Roster"
icon="users"
active={router.pathname.endsWith("roster")}
color="blue"
/>
</Link>
)}
{!course.archived && (
<Link
href="/courses/[course]/analytics"
as={`/courses/${courseId}/analytics`}
legacyBehavior
>
<Menu.Item
style={noWrapStyle}
active={router.pathname.endsWith("analytics")}
color="blue"
>
<Icon
name="chart bar"
style={{
float: "right",
margin: "0 0 0 .5em",
}}
/>
Analytics
<Label
color="violet"
content="Beta"
size="tiny"
style={{
float: "none",
verticalAlign: "bottom",
}}
/>
</Menu.Item>
</Link>
)}
{staff && (
<Link
href="/courses/[course]/summary"
as={`/courses/${courseId}/summary`}
legacyBehavior
>
<Menu.Item
style={noWrapStyle}
name="Question Summary"
icon="list ol"
active={router.pathname.endsWith("summary")}
color="blue"
/>
</Link>
)}
{!course.archived && leader && (
<Link
href="/courses/[course]/settings"
as={`/courses/${courseId}/settings`}
legacyBehavior
>
<Menu.Item
style={noWrapStyle}
name="Course Settings"
icon="settings"
href={`/courses/${courseId}/settings`}
active={router.pathname.endsWith("settings")}
color="blue"
/>
</Link>
)}
</Menu>
</Segment>
);
};
export default CourseSidebarNav;