File tree Expand file tree Collapse file tree 3 files changed +40
-18
lines changed
peerprep-fe/src/components Expand file tree Collapse file tree 3 files changed +40
-18
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { ReactElement } from 'react' ;
22import {
33 Dialog ,
44 DialogContent ,
@@ -16,6 +16,7 @@ type Props = {
1616 description : string ;
1717 callback ?: ( ) => void ;
1818 callbackTitle ?: string ;
19+ children ?: ReactElement ;
1920} ;
2021
2122const ActionDialog = ( {
@@ -26,18 +27,23 @@ const ActionDialog = ({
2627 description,
2728 callback,
2829 callbackTitle,
30+ children,
2931} : Props ) => {
3032 return (
3133 < Dialog open = { isOpen } onOpenChange = { onClose } >
32- < DialogContent className = "bg-black" >
34+ < DialogContent className = "max-h-[80%] overflow-auto bg-black" >
3335 < DialogHeader >
3436 < DialogTitle > { title } </ DialogTitle >
3537 < DialogDescription > { subtitle } </ DialogDescription >
3638 </ DialogHeader >
37- < div className = "mt-4" >
38- < h3 className = "mb-2 text-lg font-semibold" > Description:</ h3 >
39- < p > { description } </ p >
40- </ div >
39+ { children ? (
40+ children
41+ ) : (
42+ < div className = "mt-4" >
43+ < h3 className = "mb-2 text-lg font-semibold" > Description:</ h3 >
44+ < p > { description } </ p >
45+ </ div >
46+ ) }
4147 < div className = "mt-6 flex justify-end" >
4248 < Button variant = "secondary" onClick = { callback } >
4349 { callbackTitle }
Original file line number Diff line number Diff line change @@ -5,21 +5,29 @@ import { Button } from '../ui/button';
55type Props = {
66 problem : Problem ;
77 resetQuestion : ( ) => void ; // replace with something more generic
8+ hasHeader ?: boolean ;
89} ;
910
10- const ProblemDescriptionPanel = ( { problem, resetQuestion } : Props ) => {
11+ const ProblemDescriptionPanel = ( {
12+ problem,
13+ resetQuestion,
14+ hasHeader = true ,
15+ } : Props ) => {
1116 return (
1217 < >
13- < div className = "flex justify-between" >
14- < h2 className = "mb-4 text-2xl font-bold" > { problem . title } </ h2 >
15- < Button
16- variant = "outline"
17- className = "border-gray-700 bg-gray-800"
18- onClick = { ( ) => resetQuestion ( ) }
19- >
20- Reset
21- </ Button >
22- </ div >
18+ { hasHeader && (
19+ < div className = "flex justify-between" >
20+ < h2 className = "mb-4 text-2xl font-bold" > { problem . title } </ h2 >
21+ < Button
22+ variant = "outline"
23+ className = "border-gray-700 bg-gray-800"
24+ onClick = { ( ) => resetQuestion ( ) }
25+ >
26+ Reset
27+ </ Button >
28+ </ div >
29+ ) }
30+
2331 < p className = "mb-4" > { problem . description } </ p >
2432 { problem . examples . map ( ( example , index ) => (
2533 < React . Fragment key = { index } >
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import InformationDialog from '../dialogs/InformationDialog';
1010import ActionDialog from '../dialogs/ActionDialog' ;
1111import { useRouter } from 'next/navigation' ;
1212import { axiosClient } from '@/network/axiosClient' ;
13+ import ProblemDescriptionPanel from './ProblemDescriptionPanel' ;
1314
1415function ProblemStatus ( { status } : { status : string } ) {
1516 if ( status === 'solved' ) {
@@ -156,7 +157,14 @@ export default function ProblemRow({
156157 description = { problem . description }
157158 callback = { handleMatch }
158159 callbackTitle = "Match"
159- />
160+ >
161+ < ProblemDescriptionPanel
162+ problem = { problem }
163+ resetQuestion = { ( ) => { } }
164+ hasHeader = { false }
165+ />
166+ </ ActionDialog >
167+
160168 { /* Dialog for deleting question */ }
161169 < ActionDialog
162170 isOpen = { isDeleteDialogOpen }
You can’t perform that action at this time.
0 commit comments