Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/156
Browse files Browse the repository at this point in the history
  • Loading branch information
mkimberlin authored Nov 21, 2024
2 parents 4b8b794 + 038c6d5 commit 3fddecb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions web-ui/src/pages/FeedbackSubmitPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useHistory, useLocation } from 'react-router-dom';
import {
selectCsrfToken,
selectCurrentUser,
selectIsSubordinateOfCurrentUser,
selectProfile
} from '../context/selectors';
import { AppContext } from '../context/AppContext';
Expand Down Expand Up @@ -52,11 +53,6 @@ const FeedbackSubmitPage = () => {
const [requestCanceled, setRequestCanceled] = useState(false);
const feedbackRequestFetched = useRef(false);

function isManager(revieweeProfile) {
const supervisorId = revieweeProfile?.supervisorid;
return supervisorId === currentUserId;
}

useEffect(() => {
if (!requestQuery && !selfRequestQuery) {
history.push('/checkins');
Expand Down Expand Up @@ -147,12 +143,12 @@ const FeedbackSubmitPage = () => {
feedbackRequest?.recipientId
);

// If this is our review or we are the manager of the reviewer we are
// allowed to view this review.
if (recipientProfile?.id != currentUserId &&
!isManager(recipientProfile)) {
// If we know the current user and it's not the recipient or someone in the person having feedback given's
// management heirarchy, then we should issue an error and send them home...
if (currentUserId && feedbackRequest?.recipientId != currentUserId &&
!selectIsSubordinateOfCurrentUser(feedbackRequest?.requesteeId)) {
// The current user is not the recipients's manager, we need to leave.
history.push('/checkins');
history.push('/');
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
Expand All @@ -170,7 +166,7 @@ const FeedbackSubmitPage = () => {
);
setRecipient(recipientProfile);
}
}, [feedbackRequest, selfReviewRequest, state]);
}, [currentUserId, feedbackRequest, selfReviewRequest, state]);

return (
<Root className="feedback-submit-page">
Expand Down

0 comments on commit 3fddecb

Please sign in to comment.