-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from complexdatacollective/feature/end-session…
…-functionality Feature/end session functionality
- Loading branch information
Showing
6 changed files
with
144 additions
and
28 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
app/(interview)/interview/_components/FinishInterviewModal.tsx
This file contains 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,75 @@ | ||
import { type Dispatch, type SetStateAction } from 'react'; | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
} from '~/components/ui/AlertDialog'; | ||
import { useRouter } from 'next/navigation'; | ||
import { api } from '~/trpc/client'; | ||
import { usePathname } from 'next/navigation'; | ||
import { clientRevalidateTag } from '~/utils/clientRevalidate'; | ||
|
||
type FinishInterviewModalProps = { | ||
open: boolean; | ||
setOpen: Dispatch<SetStateAction<boolean>>; | ||
}; | ||
|
||
const FinishInterviewModal = ({ open, setOpen }: FinishInterviewModalProps) => { | ||
const router = useRouter(); | ||
const pathname = usePathname(); | ||
|
||
const interviewId = pathname.split('/').pop(); | ||
const { mutateAsync: finishInterview } = api.interview.finish.useMutation({ | ||
onError(error) { | ||
throw new Error(error.message); | ||
}, | ||
async onSuccess() { | ||
await clientRevalidateTag('interview.get.byId'); | ||
|
||
router.push('/interview/finished'); | ||
}, | ||
}); | ||
const handleFinishInterview = async () => { | ||
if (!interviewId) { | ||
throw new Error('No interview id found'); | ||
} | ||
await finishInterview({ id: interviewId }); | ||
}; | ||
return ( | ||
<AlertDialog open={open}> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle className="text-base"> | ||
Are you sure you want finish the interview? | ||
</AlertDialogTitle> | ||
<AlertDialogDescription className="text-sm"> | ||
Your responses cannot be changed after you finish the interview. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel | ||
onClick={() => { | ||
setOpen(false); | ||
}} | ||
> | ||
Cancel | ||
</AlertDialogCancel> | ||
<AlertDialogAction | ||
onClick={async () => { | ||
await handleFinishInterview(); | ||
}} | ||
> | ||
Finish Interview | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; | ||
|
||
export default FinishInterviewModal; |
This file contains 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 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,15 @@ | ||
import { BadgeCheck } from 'lucide-react'; | ||
|
||
export default function InterviewCompleted() { | ||
return ( | ||
<div className="flex h-screen flex-col items-center justify-center bg-[var(--nc-background)]"> | ||
<BadgeCheck className="mb-4 h-12 w-12 text-[var(--color-sea-green)]" /> | ||
<h1 className="text-3xl font-extrabold text-white"> | ||
Thank you for participating! | ||
</h1> | ||
<p className="text-lg text-white"> | ||
Your interview has been successfully completed. | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains 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 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 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