@@ -14,12 +14,17 @@ import {
14
14
Tag ,
15
15
Modal ,
16
16
Form ,
17
+ Tabs ,
18
+ Checkbox ,
19
+ Tooltip ,
20
+ Card ,
17
21
} from "antd" ;
18
22
import { Content } from "antd/es/layout/layout" ;
19
23
import {
20
24
DeleteOutlined ,
21
25
EditOutlined ,
22
26
PlusCircleOutlined ,
27
+ PlusOutlined ,
23
28
SearchOutlined ,
24
29
} from "@ant-design/icons" ;
25
30
import "./styles.scss" ;
@@ -40,6 +45,7 @@ import {
40
45
import Link from "next/link" ;
41
46
import TextArea from "antd/es/input/TextArea" ;
42
47
import { ValidateUser , VerifyTokenResponseType } from "../services/user" ;
48
+ import TabPane from "antd/es/tabs/TabPane" ;
43
49
44
50
/**
45
51
* defines the State of the page whe a user is deleing an object. Has 3 general states:
@@ -120,10 +126,9 @@ export default function QuestionListPage() {
120
126
const [ isAdmin , setIsAdmin ] = useState < boolean | undefined > ( undefined ) ;
121
127
122
128
useLayoutEffect ( ( ) => {
123
- ValidateUser ( )
124
- . then ( ( data : VerifyTokenResponseType ) => {
125
- setIsAdmin ( data . data . isAdmin ) ;
126
- } )
129
+ ValidateUser ( ) . then ( ( data : VerifyTokenResponseType ) => {
130
+ setIsAdmin ( data . data . isAdmin ) ;
131
+ } ) ;
127
132
} , [ ] ) ;
128
133
129
134
const handleEditClick = ( index : number , question : Question ) => {
@@ -248,6 +253,34 @@ export default function QuestionListPage() {
248
253
return ( ) => clearTimeout ( timeout ) ;
249
254
} , [ search ] ) ;
250
255
256
+ const [ visibleTests , setVisibleTests ] = useState < any > ( [
257
+ { key : "1" , title : "Visible Test 1" } ,
258
+ ] ) ;
259
+ const [ hiddenTests , setHiddenTests ] = useState < any > ( [ ] ) ; // FIXME: fix the type!!
260
+ const [ tabIndex , setTabIndex ] = useState ( 2 ) ;
261
+
262
+ const handleAddVisibleTest = ( ) => {
263
+ const newKey = `${ Date . now ( ) } ` ; // Use unique timestamp as key
264
+ setVisibleTests ( [ ...visibleTests , { key : newKey } ] ) ;
265
+ } ;
266
+
267
+ const handleAddHiddenTest = ( ) => {
268
+ const newKey = `${ Date . now ( ) } ` ; // Use unique timestamp as key
269
+ setHiddenTests ( [ ...hiddenTests , { key : newKey } ] ) ;
270
+ } ;
271
+
272
+ const handleRemoveVisibleTest = ( targetKey : string ) => {
273
+ if ( visibleTests . length > 1 ) {
274
+ setVisibleTests (
275
+ visibleTests . filter ( ( test : any ) => test . key !== targetKey )
276
+ ) ;
277
+ }
278
+ } ;
279
+
280
+ const handleRemoveHiddenTest = ( targetKey : string ) => {
281
+ setHiddenTests ( hiddenTests . filter ( ( test : any ) => test . key !== targetKey ) ) ;
282
+ } ;
283
+
251
284
// Table column specification
252
285
var columns : TableProps < Question > [ "columns" ] ;
253
286
if ( isAdmin ) {
@@ -343,7 +376,7 @@ export default function QuestionListPage() {
343
376
} ,
344
377
] }
345
378
>
346
- < TextArea name = "description" />
379
+ < TextArea name = "description" rows = { 12 } />
347
380
</ Form . Item >
348
381
< Form . Item
349
382
name = "complexity"
@@ -395,6 +428,93 @@ export default function QuestionListPage() {
395
428
allowClear
396
429
/>
397
430
</ Form . Item >
431
+ < Tabs defaultActiveKey = "1" >
432
+ { /* Visible Tests Tab */ }
433
+ < TabPane tab = "Visible Testcases" key = "1" >
434
+ < Tabs
435
+ type = "editable-card"
436
+ onEdit = { ( targetKey , action ) =>
437
+ action === "add"
438
+ ? handleAddVisibleTest ( )
439
+ : handleRemoveVisibleTest ( targetKey . toString ( ) )
440
+ }
441
+ >
442
+ { visibleTests . map ( ( test : any , index : number ) => (
443
+ < TabPane
444
+ tab = { `Test ${ index + 1 } ` } // Dynamic numbering based on index
445
+ key = { test . key }
446
+ closable = { visibleTests . length > 1 } // Restrict removing if only one visible test
447
+ >
448
+ < Form . Item
449
+ label = "Input"
450
+ name = { `input_${ test . key } ` }
451
+ rules = { [
452
+ {
453
+ required : true ,
454
+ message : "Please enter input value" ,
455
+ } ,
456
+ ] }
457
+ >
458
+ < Input placeholder = "Input" />
459
+ </ Form . Item >
460
+ < Form . Item
461
+ label = "Output"
462
+ name = { `output_${ test . key } ` }
463
+ rules = { [
464
+ {
465
+ required : true ,
466
+ message : "Please enter output value" ,
467
+ } ,
468
+ ] }
469
+ >
470
+ < Input placeholder = "Output" />
471
+ </ Form . Item >
472
+ </ TabPane >
473
+ ) ) }
474
+ </ Tabs >
475
+ </ TabPane >
476
+
477
+ { /* Hidden Tests Tab */ }
478
+ < TabPane tab = "Hidden Testcases" key = "2" >
479
+ < Tabs
480
+ type = "editable-card"
481
+ onEdit = { ( targetKey , action ) =>
482
+ action === "add"
483
+ ? handleAddHiddenTest ( )
484
+ : handleRemoveHiddenTest ( targetKey . toString ( ) )
485
+ }
486
+ >
487
+ { hiddenTests . map ( ( test : any , index : number ) => (
488
+ < TabPane tab = { `Test ${ index + 1 } ` } key = { test . key } >
489
+ < Form . Item
490
+ label = "Input"
491
+ name = { `input_${ test . key } ` }
492
+ rules = { [
493
+ {
494
+ required : true ,
495
+ message : "Please enter input value" ,
496
+ } ,
497
+ ] }
498
+ >
499
+ < Input placeholder = "Input" />
500
+ </ Form . Item >
501
+ < Form . Item
502
+ label = "Output"
503
+ name = { `output_${ test . key } ` }
504
+ rules = { [
505
+ {
506
+ required : true ,
507
+ message : "Please enter output value" ,
508
+ } ,
509
+ ] }
510
+ >
511
+ < Input placeholder = "Output" />
512
+ </ Form . Item >
513
+ </ TabPane >
514
+ ) ) }
515
+ </ Tabs >
516
+ </ TabPane >
517
+ </ Tabs >
398
518
< Form . Item
399
519
style = { { display : "flex" , justifyContent : "flex-end" } }
400
520
>
@@ -596,7 +716,7 @@ export default function QuestionListPage() {
596
716
} ,
597
717
] }
598
718
>
599
- < TextArea name = "description" />
719
+ < TextArea name = "description" rows = { 12 } />
600
720
</ Form . Item >
601
721
< Form . Item
602
722
name = "complexity"
0 commit comments