-
Notifications
You must be signed in to change notification settings - Fork 21
fix(PM-3141): Respond to appeals #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
da81018
5a25ed2
d216fde
b111246
548b0c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ import { | |
| } from 'react' | ||
| import { find, forEach, map } from 'lodash' | ||
| import { toast } from 'react-toastify' | ||
| import useSWR, { SWRResponse } from 'swr' | ||
| import useSWR, { SWRResponse, mutate } from 'swr' | ||
|
|
||
| import { handleError } from '~/apps/admin/src/lib/utils' | ||
|
|
||
|
|
@@ -56,6 +56,7 @@ import { ReviewItemComment } from '../models/ReviewItemComment.model' | |
| import { SUBMITTER } from '../../config/index.config' | ||
|
|
||
| import { useRole, useRoleProps } from './useRole' | ||
| import { EnvironmentConfig } from '~/config' | ||
|
|
||
| const hasSubmitterReviewDetails = (review?: BackendReview): boolean => { | ||
| if (!review) { | ||
|
|
@@ -458,7 +459,7 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis | |
| data: appeals, | ||
| error: fetchAppealsError, | ||
| }: SWRResponse<AppealInfo[], Error> = useSWR<AppealInfo[], Error>( | ||
| `EnvironmentConfig.API.V6/appeals/resourceId/${resourceId}`, | ||
| `${EnvironmentConfig.API.V6}/appeals/resourceId/${resourceId}`, | ||
| { | ||
| fetcher: () => fetchAppeals(1, 100, resourceId), | ||
| isPaused: () => !resourceId, | ||
|
|
@@ -857,8 +858,23 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis | |
|
|
||
| setIsSavingAppealResponse(true) | ||
| Promise.all(listRequest) | ||
| .then(() => { | ||
| .then(async () => { | ||
| setIsSavingAppealResponse(false) | ||
| // Revalidate SWR caches so other components using the raw SWR data update immediately | ||
| try { | ||
| if (resourceId) { | ||
| // re-fetch appeals for this resourceId | ||
| mutate(`EnvironmentConfig.API.V6/appeals/resourceId/${resourceId}`, (prev: any) => ({ ...prev, status: "processing" }), false) | ||
|
|
||
| } | ||
|
||
| if (reviewId) { | ||
| // re-fetch review data | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mutate(`EnvironmentConfig.API.V6/reviews/${reviewId}`, (prev: any) => ({ ...prev, status: "processing" }), false) | ||
| } | ||
| } catch (e) { | ||
| // ignore mutate errors | ||
| } | ||
|
|
||
| toast.success('Appeal response saved successfully!') | ||
| success() | ||
| }) | ||
|
|
@@ -867,7 +883,7 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis | |
| handleError(e) | ||
| }) | ||
| }, | ||
| [resourceId, reviewInfo, setUpdatedReviewInfo, updatedReviewInfo], | ||
| [resourceId, reviewInfo, setUpdatedReviewInfo, updatedReviewInfo, reviewId], | ||
| ) | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ export function getReviewRoute( | |
| ? `${prefix}/${match[1]}/${match[2]}` | ||
| : `/${match[1]}/${match[2]}` | ||
|
|
||
| return `${basePath}/reviews/${submissionId}?reviewId=${encodedReviewId}` | ||
| return `${basePath}/reviews/${submissionId}?reviewId=${encodedReviewId}&respondToAppeals=true` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { mutate } from 'swr' | ||
| import { FC, useCallback, useEffect, useMemo, useState } from 'react' | ||
| import { useSearchParams } from 'react-router-dom' | ||
|
|
||
| import { ChallengeLinksForAdmin } from '~/apps/review/src/lib/components/ChallengeLinksForAdmin' | ||
| import { ScorecardViewer } from '~/apps/review/src/lib/components/Scorecard' | ||
|
|
@@ -25,6 +26,8 @@ import styles from './ReviewViewer.module.scss' | |
|
|
||
| const ReviewViewer: FC = () => { | ||
| const navigate = useAppNavigate() | ||
| const [searchParams] = useSearchParams() | ||
| const [respondToAppeals, setRespondToAppeals] = useState(searchParams.get("respondToAppeals") === 'true') | ||
|
||
| const { | ||
| reviewId, | ||
| setReviewStatus, | ||
|
|
@@ -205,8 +208,11 @@ const ReviewViewer: FC = () => { | |
| useEffect(() => { | ||
| if (!canEditScorecard && isManagerEdit) { | ||
| setIsManagerEdit(false) | ||
| } else if (!isManagerEdit && respondToAppeals) { | ||
| setIsManagerEdit(true) | ||
| setRespondToAppeals(false) | ||
| } | ||
| }, [canEditScorecard, isManagerEdit]) | ||
| }, [canEditScorecard, isManagerEdit, respondToAppeals]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
|
|
||
| const toggleManagerEdit = useCallback(() => { | ||
| setIsManagerEdit(prev => !prev) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.