-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
30 lines (29 loc) · 870 Bytes
/
utils.js
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
export function makeFrontendPath(
code,
parentType,
questionID,
reviewID,
commentID
) {
// note that currently in the frontend there's no way to view an individual comment, so we just link to the parent
const [parentParentType, parentParentID] = questionID
? ['question', questionID]
: ['review', reviewID]
return `course/${code}/${parentParentType}/${parentParentID}`
}
export function makeServerPath(
code,
parentType,
questionID,
reviewID,
commentID
) {
const [parentParentType, parentParentID] = questionID
? ['question', questionID]
: ['review', reviewID]
if (parentType === 'comment') {
const commentType = questionID ? 'answer' : 'comment'
return `api/course/${code}/${parentParentType}/${parentParentID}/${commentType}/${commentID}`
}
return `api/course/${code}/${parentParentType}/${parentParentID}`
}