-
Notifications
You must be signed in to change notification settings - Fork 4
[INTW26] Conflict Dialog #247
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ac00b1b
rebase sparshs pr
2ab9f4f
clean up styling for report button
e588a62
fix: address conflict dialog review feedback
OpsEclipse d99765b
fix: align review flow with applicant record ids
OpsEclipse f01aaa7
fix: remove unrelated branch changes
OpsEclipse 1109d38
refactor: make conflictDialogue api and panellayout api more abstract
a89d53b
fix: remove stale back to home
c9b5840
revert changes on tables
14a8bea
address import comments
5a1ec00
refactor: address review cleanup comments
OpsEclipse 83a1309
refactor: first pass at decoupling the conflict dialogue component in…
mxc-maggiechen 2b1c934
refactor: clean up parsing url for applicantRecordId
mxc-maggiechen 8c77844
refactor: reset to staging for interview files, not needed for this PR
mxc-maggiechen e8f59c1
refactor: fix some typing
mxc-maggiechen 188f7ee
fix styling on modals
mxc-maggiechen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { fetchGraphql } from "@utils/makegqlrequest"; | ||
| import { mutations } from "graphql/queries"; | ||
| import BaseAPIClient from "./BaseAPIClient"; | ||
|
|
||
| export type ReportReviewConflictResult = { | ||
| readonly applicantRecordId: string; | ||
| readonly reviewerId: number; | ||
| readonly status: string; | ||
| readonly score: number; | ||
| readonly reviewerHasConflict: boolean; | ||
| }; | ||
|
|
||
| const reportReviewConflict = async ( | ||
| applicantRecordId: string, | ||
| reviewerId: number, | ||
| ): Promise<ReportReviewConflictResult> => { | ||
| BaseAPIClient.handleAuthRefresh(); | ||
| if (!Number.isInteger(reviewerId)) { | ||
| throw new Error("Reviewer ID is invalid"); | ||
| } | ||
|
|
||
| const result = await fetchGraphql(mutations.reportReviewConflict, { | ||
| applicantRecordId, | ||
| reviewerId, | ||
| }); | ||
| const conflictResult = result?.data?.reportReviewConflict; | ||
|
|
||
| if (!conflictResult) { | ||
| throw new Error("Conflict report request returned no data"); | ||
| } | ||
|
|
||
| return conflictResult; | ||
| }; | ||
|
|
||
| export default { | ||
| reportReviewConflict, | ||
| }; |
|
OpsEclipse marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import React, { ReactElement, ReactNode, Children } from "react"; | ||
| import Dialog from "@mui/material/Dialog"; | ||
| import { useTheme } from "@mui/material/styles"; | ||
|
|
||
| type Props = { | ||
| readonly open: boolean; | ||
| readonly onClose: () => void; | ||
| readonly header: string; | ||
| readonly text: ReactNode; | ||
| readonly children?: ReactNode; | ||
| readonly textContainerClassName?: string; | ||
| }; | ||
|
|
||
| const Dialogue = ({ | ||
| open, | ||
| onClose, | ||
| header, | ||
| text, | ||
| children, | ||
| textContainerClassName, | ||
| }: Props): ReactElement => { | ||
|
OpsEclipse marked this conversation as resolved.
Outdated
|
||
| const textContainerClasses = | ||
| `flex w-full flex-col items-center gap-2 text-center ${ | ||
| textContainerClassName ?? "" | ||
| }`.trim(); | ||
|
OpsEclipse marked this conversation as resolved.
Outdated
|
||
|
|
||
| const theme = useTheme(); | ||
|
|
||
| const actionChildren = Children.toArray(children).filter(Boolean); | ||
| const hasSingleAction = actionChildren.length === 1; | ||
| const actionsContainerClasses = hasSingleAction | ||
| ? "flex w-full items-center justify-center" | ||
| : "flex w-full items-center justify-center gap-4"; | ||
|
|
||
| const actionWrapperClass = hasSingleAction ? "w-full" : "flex-1"; | ||
|
OpsEclipse marked this conversation as resolved.
Outdated
|
||
|
|
||
| return ( | ||
| <Dialog | ||
| open={open} | ||
| onClose={onClose} | ||
| maxWidth={false} | ||
| PaperProps={{ | ||
| sx: { | ||
| borderRadius: 2, | ||
| overflow: "hidden", | ||
| boxShadow: "none", | ||
| opacity: 1, | ||
| }, | ||
| }} | ||
| > | ||
| <div | ||
| className="flex flex-col justify-center items-center gap-[36px] p-6" | ||
| style={{ | ||
| width: "310px", | ||
| backgroundColor: theme.palette.background.paper, | ||
| }} | ||
| > | ||
| <div className={textContainerClasses}> | ||
| <h2 | ||
| className="w-full font-poppins text-[20px] font-medium leading-[1.4]" | ||
| style={{ color: theme.palette.primary.main }} | ||
| > | ||
| {header} | ||
| </h2> | ||
| <div | ||
| className="w-full font-source text-[14px] font-normal leading-[1.4]" | ||
| style={{ color: theme.palette.text.primary }} | ||
| > | ||
| {text} | ||
| </div> | ||
| </div> | ||
| {actionChildren.length > 0 ? ( | ||
| <div className={actionsContainerClasses}> | ||
| {actionChildren.map((child, idx) => ( | ||
| <div className={actionWrapperClass} key={idx}> | ||
|
OpsEclipse marked this conversation as resolved.
Outdated
|
||
| {child} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| ) : null} | ||
| </div> | ||
| </Dialog> | ||
|
OpsEclipse marked this conversation as resolved.
|
||
| ); | ||
| }; | ||
|
|
||
| export default Dialogue; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import Button from "@components/common/Button"; | ||
| import Dialogue from "@components/common/Dialogue"; | ||
| import ReviewPageAPIClient from "APIClients/ReviewPageAPIClient"; | ||
| import { useTheme } from "@mui/material/styles"; | ||
| import { useRouter } from "next/router"; | ||
| import { ReactElement, useState } from "react"; | ||
| import { BACK_TO_HOME_HREF } from "./constants"; | ||
|
|
||
| type Props = { | ||
| readonly applicantRecordId: string | null; | ||
| readonly reviewerId: number | null; | ||
| readonly confirmOpen: boolean; | ||
| readonly onConfirmOpenChange: (open: boolean) => void; | ||
| }; | ||
|
|
||
| const ConflictDialogue = ({ | ||
| applicantRecordId, | ||
| reviewerId, | ||
| confirmOpen, | ||
| onConfirmOpenChange, | ||
| }: Props): ReactElement => { | ||
| const theme = useTheme(); | ||
| const router = useRouter(); | ||
|
|
||
| const [successDialogOpen, setSuccessDialogOpen] = useState(false); | ||
| const [isReporting, setIsReporting] = useState(false); | ||
| const [reportError, setReportError] = useState<string | null>(null); | ||
|
|
||
| const handleCloseConfirmDialog = () => { | ||
| if (isReporting) { | ||
| return; | ||
| } | ||
| setReportError(null); | ||
| onConfirmOpenChange(false); | ||
| }; | ||
|
|
||
| const handleBackToHomepage = () => { | ||
| setSuccessDialogOpen(false); | ||
| router.push(`/${BACK_TO_HOME_HREF}`); | ||
| }; | ||
|
|
||
| const handleReportConflict = async () => { | ||
| try { | ||
| setIsReporting(true); | ||
| setReportError(null); | ||
|
|
||
| if (applicantRecordId == null) { | ||
| throw new Error("Missing applicantRecordId in URL"); | ||
| } | ||
|
|
||
| if (reviewerId == null || !Number.isInteger(reviewerId)) { | ||
| throw new Error("Missing authenticated reviewer ID"); | ||
| } | ||
|
|
||
| await ReviewPageAPIClient.reportReviewConflict( | ||
| applicantRecordId, | ||
| reviewerId, | ||
| ); | ||
|
|
||
| onConfirmOpenChange(false); | ||
| setSuccessDialogOpen(true); | ||
| } catch (error) { | ||
| setReportError("Couldn't report conflict. Please try again."); | ||
| } finally { | ||
| setIsReporting(false); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
|
OpsEclipse marked this conversation as resolved.
Outdated
|
||
| <> | ||
| <Dialogue | ||
| open={confirmOpen} | ||
| onClose={handleCloseConfirmDialog} | ||
| header="Report as conflict of interest?" | ||
| text={ | ||
| <div className="flex flex-col gap-2"> | ||
| <span>Clicking yes will notify admins and cannot be undone.</span> | ||
| {reportError ? ( | ||
| <span style={{ color: theme.palette.error.main }} role="alert"> | ||
| {reportError} | ||
| </span> | ||
| ) : null} | ||
| </div> | ||
| } | ||
| > | ||
| <Button | ||
| variant="secondary" | ||
| size="md" | ||
| onClick={handleCloseConfirmDialog} | ||
| className="whitespace-nowrap" | ||
| disabled={isReporting} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| <Button | ||
| variant="primary" | ||
| size="md" | ||
| onClick={handleReportConflict} | ||
| className="whitespace-nowrap" | ||
| disabled={isReporting} | ||
| > | ||
| Yes, report | ||
| </Button> | ||
| </Dialogue> | ||
|
|
||
| <Dialogue | ||
| open={successDialogOpen} | ||
| onClose={() => setSuccessDialogOpen(false)} | ||
| header="Conflict reported!" | ||
| text="This applicant has been reported as a conflict of interest and will be re-assigned to another reviewer." | ||
| > | ||
| <Button | ||
| variant="primary" | ||
| size="md" | ||
| onClick={handleBackToHomepage} | ||
| className="whitespace-nowrap" | ||
| > | ||
| Back to homepage | ||
| </Button> | ||
| </Dialogue> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default ConflictDialogue; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { LongLeftIcon } from "@components/icons/long-left.icon"; | ||
| import Link from "next/link"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| interface ReviewStageHeaderProps { | ||
| backHref: string; | ||
| right?: ReactNode; | ||
| } | ||
|
|
||
| export const ReviewStageHeader = ({ | ||
| backHref, | ||
| right, | ||
| }: ReviewStageHeaderProps) => { | ||
| return ( | ||
| <> | ||
| <Link href={backHref} passHref> | ||
| <a className="font-source no-underline inline-flex justify-center items-center gap-2 w-fit cursor-pointer shrink-0 hover:opacity-90 rounded-full py-2 px-4 border-2 border-blue bg-white text-blue text-base font-normal leading-[1.4] hover:bg-sky-100 hover:border-blue hover:text-blue"> | ||
| <LongLeftIcon /> | ||
| Back to home | ||
| </a> | ||
| </Link> | ||
| {right != null ? ( | ||
| <div className="shrink-0 flex items-center">{right}</div> | ||
| ) : null} | ||
| </> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.