Skip to content

Commit

Permalink
refactor: update clientside access right checks to check from array -…
Browse files Browse the repository at this point in the history
…refs: #1392
  • Loading branch information
HRemonen committed Dec 2, 2024
1 parent 499a5fa commit f866839
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/client/pages/FeedbackTarget/FeedbackTargetContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const FeedbackTargetContextProvider = ({ id, isAdmin, organisation, feedb
const orgAccess = organisation?.access
const accessStatus = feedbackTarget?.accessStatus

const isResponsibleTeacher = accessStatus === 'RESPONSIBLE_TEACHER' || isAdmin
const isTeacher = accessStatus === 'TEACHER' || isResponsibleTeacher || isAdmin
const isStudent = accessStatus === 'STUDENT'
const isResponsibleTeacher = accessStatus.includes('RESPONSIBLE_TEACHER') || isAdmin
const isTeacher = accessStatus.includes('TEACHER') || isResponsibleTeacher || isAdmin
const isStudent = accessStatus.includes('STUDENT')
const isOrganisationAdmin = orgAccess?.admin || isAdmin
const isOrganisationReader = orgAccess?.read || isAdmin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const FeedbackView = () => {
const { language } = i18n
const { accessStatus, opensAt, closesAt, feedback, continuousFeedbackEnabled } = feedbackTarget

const isOutsider = accessStatus === 'NONE'
const isOutsider = accessStatus.includes('NONE')
const isEnded = feedbackTargetIsEnded(feedbackTarget)
const isOpen = feedbackTargetIsOpen(feedbackTarget)
const isOngoing = !isOpen && !isEnded
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/GuestUser/GuestFeedbackTargetView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const GuestFeedbackTargetView = () => {
const isOpen = feedbackTargetIsOpen(feedbackTarget)
const isEnded = feedbackTargetIsEnded(feedbackTarget)
const isStarted = new Date() >= new Date(opensAt)
const isTeacher = accessStatus === 'TEACHER' || accessStatus === 'RESPONSIBLE_TEACHER'
const isTeacher = accessStatus.includes('TEACHER') || accessStatus.includes('RESPONSIBLE_TEACHER')
const showFeedbacksTab = (isTeacher && isStarted) || feedback || isEnded

const coursePeriod = getCoursePeriod(courseRealisation)
Expand Down

0 comments on commit f866839

Please sign in to comment.