Skip to content

Commit 48803b3

Browse files
authored
Merge branch 'develop' into bugfix-2660/volunteer-tracking
2 parents 4994b58 + 8063be0 commit 48803b3

File tree

3 files changed

+20
-196
lines changed

3 files changed

+20
-196
lines changed

web-ui/src/components/reviews/TeamMemberReview.jsx

Lines changed: 15 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ import {
2020
Typography
2121
} from '@mui/material';
2222
import FeedbackSubmitForm from '../feedback_submit_form/FeedbackSubmitForm';
23-
import SelectUserModal from './SelectUserModal';
24-
import { cancelFeedbackRequest, updateFeedbackRequest } from '../../api/feedback';
25-
import { UPDATE_TOAST } from '../../context/actions';
2623

2724
const propTypes = {
2825
selfReview: PropTypes.any,
@@ -97,27 +94,7 @@ const TeamMemberReview = ({
9794
const csrf = selectCsrfToken(state);
9895
const currentUser = selectCurrentUser(state);
9996
const theme = useTheme();
100-
const [value, setValue] = useState(0);
101-
const [init, setInit] = useState(true);
102-
const [reassignOpen, setReassignOpen] = useState(false);
103-
const [cancelOpen, setCancelOpen] = useState(false);
104-
105-
const handleOpenReassign = useCallback(
106-
() => setReassignOpen(true),
107-
[setReassignOpen]
108-
);
109-
const handleCloseReassign = useCallback(
110-
() => setReassignOpen(false),
111-
[setReassignOpen]
112-
);
113-
const handleOpenCancel = useCallback(
114-
() => setCancelOpen(true),
115-
[setCancelOpen]
116-
);
117-
const handleCloseCancel = useCallback(
118-
() => setCancelOpen(false),
119-
[setCancelOpen]
120-
);
97+
const [value, setValue] = useState(1);
12198

12299
const review = reviews && reviews[value - 1];
123100
const recipient = selectProfile(state, review?.recipientId);
@@ -130,91 +107,9 @@ const TeamMemberReview = ({
130107
setValue(index);
131108
};
132109

133-
const handleCancelClick = useCallback(() => {
134-
const cancelRequest = async () => {
135-
const res = await cancelFeedbackRequest(review, csrf);
136-
const cancellationResponse =
137-
res && res.payload && res.payload.status === 200 && !res.error
138-
? res.payload.data
139-
: null;
140-
if (!cancellationResponse) {
141-
window.snackDispatch({
142-
type: UPDATE_TOAST,
143-
payload: {
144-
severity: 'error',
145-
toast:
146-
'There was an error cancelling the review. Please contact your administrator.'
147-
}
148-
});
149-
}
150-
return cancellationResponse;
151-
};
152-
153-
handleCloseCancel();
154-
if (csrf) {
155-
cancelRequest().then(res => {
156-
if (res) {
157-
reloadReviews();
158-
window.snackDispatch({
159-
type: UPDATE_TOAST,
160-
payload: {
161-
severity: 'success',
162-
toast: 'Review canceled'
163-
}
164-
});
165-
}
166-
});
167-
}
168-
}, [csrf, handleCloseCancel, review, reloadReviews]);
169-
170-
const handleReassign = useCallback(
171-
assignee => {
172-
const reassignRequest = async () => {
173-
review.recipientId = assignee.id;
174-
const res = await updateFeedbackRequest(review, csrf);
175-
const updateResponse =
176-
res && res.payload && res.payload.status === 200 && !res.error
177-
? res.payload.data
178-
: null;
179-
if (!updateResponse) {
180-
window.snackDispatch({
181-
type: UPDATE_TOAST,
182-
payload: {
183-
severity: 'error',
184-
toast:
185-
'There was an error reassigning the review. Please contact your administrator.'
186-
}
187-
});
188-
}
189-
return updateResponse;
190-
};
191-
192-
handleCloseReassign();
193-
if (csrf) {
194-
reassignRequest().then(res => {
195-
if (res) {
196-
reloadReviews();
197-
window.snackDispatch({
198-
type: UPDATE_TOAST,
199-
payload: {
200-
severity: 'success',
201-
toast: 'Review reassigned'
202-
}
203-
});
204-
}
205-
});
206-
}
207-
},
208-
[csrf, handleCloseReassign, review, reloadReviews]
209-
);
210-
211110
let selfReviewIcon = <HourglassEmptyIcon />;
212111
if (selfReview && selfReview.status?.toUpperCase() === 'SUBMITTED') {
213112
selfReviewIcon = <CheckCircleIcon />;
214-
} else if (init) {
215-
// If there is no self-review, switch to the next tab.
216-
setInit(false);
217-
setValue(1);
218113
}
219114

220115
return (
@@ -228,25 +123,21 @@ const TeamMemberReview = ({
228123
textColor="inherit"
229124
variant="fullWidth"
230125
>
231-
{selfReview && selfReview.id && (<Tab
126+
<Tab
232127
icon={selfReviewIcon}
233128
label={
234129
memberProfile?.firstName
235130
? memberProfile?.firstName + "'s Self-Review"
236131
: 'Self-Review'
237132
}
238133
{...a11yProps(0)}
239-
/>)}
134+
/>
240135
{reviews &&
241-
reviews.map((review, index) => {
242-
if (!review) {
243-
return (<></>);
244-
}
136+
reviews.filter(r => !!r).map((review, index) => {
245137
const reviewer = review.recipientId == memberProfile?.id ?
246138
memberProfile :
247139
selectProfile(state, review.recipientId);
248140
let label = reviewer?.firstName + "'s Review";
249-
250141
if (reviewer?.id === currentUser?.id) {
251142
label = 'Your Review';
252143
}
@@ -267,24 +158,20 @@ const TeamMemberReview = ({
267158
index={value}
268159
onChangeIndex={handleChangeIndex}
269160
>
270-
{selfReview && selfReview.id && (
271161
<TabPanel value={value} index={0} dir={theme.direction}>
272-
<FeedbackSubmitForm
273-
requesteeName={
274-
memberProfile?.firstName + ' ' + memberProfile?.lastName
275-
}
276-
requestId={selfReview?.id}
277-
request={selfReview}
278-
reviewOnly={true}
279-
/>
162+
{selfReview?.id ? (
163+
<FeedbackSubmitForm
164+
requesteeName={
165+
memberProfile?.firstName + ' ' + memberProfile?.lastName
166+
}
167+
requestId={selfReview?.id}
168+
request={selfReview}
169+
reviewOnly={true}
170+
/>
171+
) : (<Typography variant="h4">Not Available</Typography>)}
280172
</TabPanel>
281-
)}
282173
{reviews &&
283-
reviews.map((review, index) => {
284-
if (!review) {
285-
return (<></>);
286-
}
287-
174+
reviews.filter(r => !!r).map((review, index) => {
288175
const reviewer = selectProfile(state, review.recipientId);
289176
const requestee = selectProfile(state, review.requesteeId);
290177
const requesteeName = requestee?.name;
@@ -293,26 +180,6 @@ const TeamMemberReview = ({
293180

294181
return (
295182
<TabPanel value={value} index={index + 1} dir={theme.direction}>
296-
{review && review.status?.toUpperCase() !== 'SUBMITTED' && (
297-
<div className={classes.buttonRow}>
298-
<Button
299-
onClick={handleOpenCancel}
300-
className={classes.actionButtons}
301-
variant="outlined"
302-
color="secondary"
303-
>
304-
Cancel
305-
</Button>
306-
<Button
307-
onClick={handleOpenReassign}
308-
className={classes.actionButtons}
309-
variant="outlined"
310-
color="primary"
311-
>
312-
Reassign
313-
</Button>
314-
</div>
315-
)}
316183
<FeedbackSubmitForm
317184
requesteeName={requesteeName}
318185
requestId={review.id}
@@ -323,39 +190,6 @@ const TeamMemberReview = ({
323190
);
324191
})}
325192
</SwipeableViews>
326-
<SelectUserModal
327-
userLabel="Reviewer"
328-
open={reassignOpen}
329-
onSelect={handleReassign}
330-
onClose={handleCloseReassign}
331-
/>
332-
<Modal open={cancelOpen} onClose={handleCloseCancel}>
333-
<Card className="cancel-feedback-request-modal">
334-
<CardHeader
335-
title={
336-
<Typography variant="h5" fontWeight="bold">
337-
Cancel Review
338-
</Typography>
339-
}
340-
/>
341-
<CardContent>
342-
<Typography variant="body1">
343-
Are you sure you want to cancel the review sent to{' '}
344-
<b>{recipient?.name}</b> on <b>{review?.sendDate}</b>? The
345-
recipient will not be able to respond to this request once it is
346-
canceled.
347-
</Typography>
348-
</CardContent>
349-
<CardActions>
350-
<Button color="secondary" onClick={handleCloseReassign}>
351-
No, Keep Feedback Request
352-
</Button>
353-
<Button color="primary" onClick={handleCancelClick}>
354-
Yes, Cancel Feedback Request
355-
</Button>
356-
</CardActions>
357-
</Card>
358-
</Modal>
359193
</Box>
360194
</Root>
361195
);

web-ui/src/components/reviews/TeamReviews.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,12 @@ const TeamReviews = ({ onBack, periodId }) => {
735735
recipientProfile?.supervisorid === currentUser?.id;
736736
const selfSubmitted = selfReviewRequest?.status == 'submitted';
737737
if (manages) {
738-
let separator = '?';
739-
url = "/feedback/submit";
738+
url = "/feedback/submit?tabs=true";
740739
if (request) {
741-
url += `${separator}request=${request.id}`;
742-
separator = '&';
740+
url += `&request=${request.id}`;
743741
}
744742
if (selfSubmitted) {
745-
url += `${separator}selfrequest=${selfReviewRequest.id}`;
746-
separator = '&';
743+
url += `&selfrequest=${selfReviewRequest.id}`;
747744
}
748745
}
749746
}

web-ui/src/pages/FeedbackSubmitPage.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const FeedbackSubmitPage = () => {
4040
const location = useLocation();
4141
const history = useHistory();
4242
const query = queryString.parse(location?.search);
43+
const tabs = query.tabs?.toString();
4344
const requestQuery = query.request?.toString();
4445
const selfRequestQuery = query.selfrequest?.toString();
4546
const [showTips, setShowTips] = useState(true);
@@ -123,7 +124,6 @@ const FeedbackSubmitPage = () => {
123124
) {
124125
getFeedbackRequest(selfRequestQuery, csrf).then(request => {
125126
if (request) {
126-
// Permission to view this feedback request will be checked later.
127127
setSelfReviewRequest(request);
128128
}
129129
});
@@ -169,13 +169,6 @@ const FeedbackSubmitPage = () => {
169169
selfReviewRequest?.recipientId
170170
);
171171
setRecipient(recipientProfile);
172-
173-
if (!isManager(recipientProfile)) {
174-
// The current user is not the recipient's manager, we need to clear
175-
// out the self review request so that we do not display something that
176-
// we shouldn't, on the next page.
177-
setSelfReviewRequest(null);
178-
}
179172
}
180173
}, [feedbackRequest, selfReviewRequest, state]);
181174

@@ -185,7 +178,7 @@ const FeedbackSubmitPage = () => {
185178
<Typography className={classes.announcement} variant="h3">
186179
This feedback request has been canceled.
187180
</Typography>
188-
) : requestSubmitted || selfReviewRequest ? (
181+
) : tabs || requestSubmitted || selfReviewRequest ? (
189182
<TeamMemberReview
190183
reviews={[feedbackRequest]}
191184
selfReview={selfReviewRequest}

0 commit comments

Comments
 (0)