You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{/* TODO (Sean): Include Logic to handle retrieving of editable data here and display in a modal component */}
299
307
<Modal
300
308
title="Edit Problem"
301
309
open={isEditModalOpen&&isEditModalOpen[index]}
@@ -390,11 +398,14 @@ export default function Home() {
390
398
</Form.Item>
391
399
</Form>
392
400
</Modal>
393
-
<Button
394
-
className="edit-button"
395
-
icon={<EditOutlined/>}
396
-
onClick={()=>handleEditClick(index,question)}
397
-
></Button>
401
+
{
402
+
isAdmin&&
403
+
<Button
404
+
className="edit-button"
405
+
icon={<EditOutlined/>}
406
+
onClick={()=>handleEditClick(index,question)}
407
+
></Button>
408
+
}
398
409
{/* TODO (Ryan): Include Pop-up confirmation for delete when clicked and link to delete API --> can also explore success notification or look into react-toast*/}
399
410
<Button
400
411
className="delete-button"
@@ -484,115 +495,117 @@ export default function Home() {
484
495
<divclassName="content-card">
485
496
<divclassName="content-row-1">
486
497
<divclassName="content-title">Problems</div>
487
-
<divclassName="create-button">
488
-
{/* TODO (Sean): Launch a popup modal that links to the backend api to create a new entry in db, --> look into success/error notification/react toast */}
489
-
<Button
490
-
type="primary"
491
-
icon={<PlusCircleOutlined/>}
492
-
onClick={showNewProblemModal}
493
-
>
494
-
Create New Problem
495
-
</Button>
496
-
<Modal
497
-
title="Create New Problem"
498
-
open={isNewProblemModalOpen}
499
-
// onOk={() => setIsNewProblemModelOpen(false)} // Replace with handleSubmit
500
-
onCancel={()=>setIsNewProblemModelOpen(false)}
501
-
footer={null}
502
-
width={600}
503
-
>
504
-
<Form
505
-
name="create-form"
506
-
{...layout}
507
-
form={form}
508
-
onFinish={(values)=>{
509
-
handleCreateQuestion(values);
510
-
}}
498
+
{
499
+
isAdmin&&
500
+
<divclassName="create-button">
501
+
<Button
502
+
type="primary"
503
+
icon={<PlusCircleOutlined/>}
504
+
onClick={showNewProblemModal}
511
505
>
512
-
<Form.Item
513
-
name="title"
514
-
label="Title"
515
-
rules={[
516
-
{
517
-
required: true,
518
-
message: "Please enter question title!",
519
-
},
520
-
]}
521
-
>
522
-
<Inputname="title"/>
523
-
</Form.Item>
524
-
<Form.Item
525
-
name="description"
526
-
label="Description"
527
-
rules={[
528
-
{
529
-
required: true,
530
-
message: "Please enter question description!",
531
-
},
532
-
]}
533
-
>
534
-
<TextAreaname="description"/>
535
-
</Form.Item>
536
-
<Form.Item
537
-
name="complexity"
538
-
label="Complexity"
539
-
rules={[
540
-
{
541
-
required: true,
542
-
message: "Please select a complexity!",
543
-
},
544
-
]}
506
+
Create New Problem
507
+
</Button>
508
+
<Modal
509
+
title="Create New Problem"
510
+
open={isNewProblemModalOpen}
511
+
// onOk={() => setIsNewProblemModelOpen(false)} // Replace with handleSubmit
512
+
onCancel={()=>setIsNewProblemModelOpen(false)}
513
+
footer={null}
514
+
width={600}
515
+
>
516
+
<Form
517
+
name="create-form"
518
+
{...layout}
519
+
form={form}
520
+
onFinish={(values)=>{
521
+
handleCreateQuestion(values);
522
+
}}
545
523
>
546
-
<Select
547
-
options={[
524
+
<Form.Item
525
+
name="title"
526
+
label="Title"
527
+
rules={[
548
528
{
549
-
label: "Easy",
550
-
value: "easy",
529
+
required: true,
530
+
message: "Please enter question title!",
551
531
},
532
+
]}
533
+
>
534
+
<Inputname="title"/>
535
+
</Form.Item>
536
+
<Form.Item
537
+
name="description"
538
+
label="Description"
539
+
rules={[
552
540
{
553
-
label: "Medium",
554
-
value: "medium",
541
+
required: true,
542
+
message: "Please enter question description!",
555
543
},
544
+
]}
545
+
>
546
+
<TextAreaname="description"/>
547
+
</Form.Item>
548
+
<Form.Item
549
+
name="complexity"
550
+
label="Complexity"
551
+
rules={[
556
552
{
557
-
label: "Hard",
558
-
value: "hard",
553
+
required: true,
554
+
message: "Please select a complexity!",
559
555
},
560
556
]}
561
-
onChange={(value)=>
562
-
form.setFieldValue("complexity",value)
563
-
}
564
-
allowClear
565
-
/>
566
-
</Form.Item>
567
-
<Form.Item
568
-
name="categories"
569
-
label="Categories"
570
-
rules={[
571
-
{
572
-
required: true,
573
-
message: "Please select the relevant categories!",
0 commit comments